Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Simple C++ Class problem
Name: Photomotoz Date: November 24, 2008 at 10:39:19 Pacific OS: g CPU/Ram: g Product: g
Comment:
Hey, guys I think this is a very simple problem and that I just can't get it is due to some gap in my knowledge. Any way, what is wrong with this :
class A{ private: int value; public : A(int v); };
A::A(int v) {value = v;}
//Does not work class B {A ob(5);}; //Works main(){A ob(5);}
Name: klint Date: November 25, 2008 at 02:31:30 Pacific
Reply:
class B {A ob(5);};
That looks like you're trying to define class B, containing an A object as a private data member called ob. Is that what you're trying to do? If so, you can't initialize ob inside the class definition, because at that point you're telling the compiler what structure the class has, not what values each of its instances should contain. You need to initialize it in B's constructor.
Summary: Hi everyone, I am new to Linux mandrake7.1, My simple C++ program shown below give errors when compile #include void main() { cout <<"HI";//ERROR undefined reference } ***************ERROR SHOW ...
Summary: I am experiencing the following problems when trying to compile my code using Microsoft Visual C++: class type redefinition errors Basically, I am to have one main "parent class" definition file, wit...
Summary: I had encounter some problem with mine programme project. I wish to store a string in the output. but with scanf i can't do it. if i use gets i will face some other problem too. this is mine source co...