R
Ramprasad A Padmanabhan
Hi all,
I am a C & perl programmer trying my hand at c++. Can someone tell
whats wrong with this
--------------------------------------------------
using namespace std;
#include <iostream>
class Myobj {
public :
static int count;
Myobj(){
cout <<"Creating a new obj \n";
count++;
}
};
int main() {
Myobj *x,y;
x = new Myobj();
exit(0);
}
------------------------------------------------------------
My program does not compile on linux I get an error
g++ n4.cpp -o n4
/tmp/ccLKO0S2.o(.gnu.linkonce.t._ZN5MyobjC1Ev+0x1d): In function
`Myobj::Myobj[in-charge]()':
: undefined reference to `Myobj::count'
collect2: ld returned 1 exit status
make: *** [n4] Error 1
Thanks
Ram
I am a C & perl programmer trying my hand at c++. Can someone tell
whats wrong with this
--------------------------------------------------
using namespace std;
#include <iostream>
class Myobj {
public :
static int count;
Myobj(){
cout <<"Creating a new obj \n";
count++;
}
};
int main() {
Myobj *x,y;
x = new Myobj();
exit(0);
}
------------------------------------------------------------
My program does not compile on linux I get an error
g++ n4.cpp -o n4
/tmp/ccLKO0S2.o(.gnu.linkonce.t._ZN5MyobjC1Ev+0x1d): In function
`Myobj::Myobj[in-charge]()':
: undefined reference to `Myobj::count'
collect2: ld returned 1 exit status
make: *** [n4] Error 1
Thanks
Ram