I know little bit java now I am trying to learn c I am using visual c++ studio to compile it works
I want to know the different bitten these two
sensor_perpond::sensor_perpond(void) {}
sensor_perpond::~sensor_perpond(void){...
can someone explain me this
my file name is sensor_perpond.
I don’t know what is :: mean and what is ::~ mean
And please send me some link to learn c and Assembler language. (expecting explanation and examples in the link)
Need explanation for code? F1?
The first one is a constructor for the class "sensor_perpond" and the second one is it's destructor. Constructors for a class are represented by a function with the name of the class, as a member of the class and destructors are represented by tilde "~" followed by a function with the name of the class, as a member of the class. Both should be public.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Eg 1: Both defined inside the class
class classname
{
public:
classname(...) {...} //definition of constructor for class classname
~classname(...) {...} //definition of destructor for class classname
};
Eg 2: Both defined outside the class
class classname
{
public:
classname(...); //declaration of constructor for class classname
~classname(...);//declaration of destructor for class classname
};
classname::classname(...) {...} //constructor for class classname defined outside of the class
classname::~classname(...) {...} //destructor for class classname defined outside of the class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
They are accessed using "::" (the scope resolution operator) as
classname::classname(...); // for calling constructor
classname::~classname(...); // for calling destructor
Hope it helps :)
Reply:Tutorial links
http://www.cplusplus.com/doc/t...
http://www.gnacademy.org/text/...
http://www.cprogramming.com/tu...
http://members.tripod.com/sund...
http://www.glenmccl.com/tutor....
Hope it helps :) Report It
Reply:I am sorry that the last two methods i.e. the methods of accessing the constructor and destructor were incorrect. You can however get the correct method from the tutorials above. Anyway, have a nice experience learning C++. :-) Report It
Reply:Try some of these,
Program Language Tutorials:
http://www.freeprogrammingresources.com/...
http://www.programmertutorials.com/
http://www.programmingtutorials.com/vbne...
http://www.programmertutorials.com/tutor...
Have fun but be safe!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment