c++ class keeps crashing


 
Thread Tools Search this Thread
Top Forums Programming c++ class keeps crashing
# 1  
Old 02-09-2007
Question c++ class keeps crashing

i just started learning to prog in c++, im using netbeans.
i tryed to make a class and i keep getting this error. what am i doing wrong ?
-----------------------------
class test
{
public:
int funtime();

private:
int time;
};

int test::funtime()
{
return time;
}


---------------------------
when i try to build
i keep getting the error
/home/leandro/netbeans/testjes/testklasse.cc:13: multiple definition of `test::funtime()'

thnx in advance Smilie
# 2  
Old 02-09-2007
Did you try compiling it on the command line, e.g.

g++ test.cpp -c -o test.o

? Your pasted snippet works for me.
# 3  
Old 02-09-2007
mmm ill explain better
-------------------------
overvieuw
Image
main
Image
class rubbish that gives the error
Image
my output
Image
# 4  
Old 02-09-2007
change the filename to rubbish.h where you define the class rubbish, and include it as # include "rubbish.h" in the main file. Otherwise i don't see anything else wrong.
# 5  
Old 02-11-2007
Quote:
Originally Posted by milhan
change the filename to rubbish.h where you define the class rubbish, and include it as # include "rubbish.h" in the main file. Otherwise i don't see anything else wrong.

that worked thnx Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies

2. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

3. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

4. UNIX for Dummies Questions & Answers

Random Crashing

Over the last month or so my CentOS server has been crashing for reasons I do not know. It has been running for over a year with regular yum updates without problems. The load on the server is perfectly normal with CPU usage at 5-6% and RAM usage at less than half of 32GB of RAM (multiple smaller... (3 Replies)
Discussion started by: spinner0205
3 Replies

5. Programming

static use for class inside the same class c++

Hi, I believe the next code is wrong: class Egg { Egg e; int i; Egg(int ii=0) : i(ii) {} }; because you would end up with an endless definition (memory allocation) of Egg objects, thus int i. Ok, so God Eckel proposes for a singleton: class Egg { static Egg e; int... (5 Replies)
Discussion started by: xavipoes
5 Replies

6. UNIX and Linux Applications

Firefox crashing

Firefox keeps on crashing every time I try to run it. I tried to create a new profile with no luck. When I try to open up the profile manager firefox crashes. I even deleted my profile folder and tried to start with a new profile. That did not work either. I don't know what the problem could be. I... (6 Replies)
Discussion started by: cokedude
6 Replies

7. Programming

C++ class definition with a member of the same class

Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento) typedef struct elemento { char name; char value; List<struct elemento> ltElementos; ... (7 Replies)
Discussion started by: pogdorica
7 Replies

8. Red Hat

Fedora 11 crashing help

Using Fedora 11, just about every day the system started crashing. Becomes unresponsive to keyboard/mouse, nothing appears on screen but box is still running. Still responds to ping, arp address stays alive in the firewall, other than that its unresponsive Where can I look to find out... (1 Reply)
Discussion started by: ippy98
1 Replies

9. UNIX for Dummies Questions & Answers

car class (not school class)

im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
Discussion started by: rickym2626
1 Replies

10. Solaris

Solaris 10 crashing

Hi, My system is crashing with following error .. i tried to boot from the network and unencapsulated the root disk from SVM .. but still not able to boot the box , can any one point me to some direction .. i do not want to build the box new as of now just want to troubleshoot if possible.. ... (3 Replies)
Discussion started by: fugitive
3 Replies
Login or Register to Ask a Question