Monday, July 27, 2009

How can i kno the different types of function declaration in c++? i'm always cofusused with it?

i'm a beginner to c++. i'm confused with different type of function declarations and object creation. can u help me? here i include some func declarations.


1) int Add(CarPart* Item);


2)ListOfParts::ListOfParts()


: size(0) etc. can u explain these kind of function declarations?

How can i kno the different types of function declaration in c++? i'm always cofusused with it?
1. the functions returns an int value


the name of the function is Add


as a parameter the function takes in a carPart pointer





2. ListOfParis::ListOfParis


ListOfParis is the name of the class and here the second ListOfParis is the name of the function, here it is the constructor. Since, the constructor is written outside the class body we use the scope resolution operator :: to bind it to the class.





if u have more specific questions put it across, for general one refer some C++ book..
Reply:Read c++ book carefully.
Reply:As others have said, you should read your C++ book. Then you'll understand. The first one can be understood if you understand how functions are declared and what pointers are. The second one can be understood if you cover classes, constructors, and initialization lists. Both are discussed in C++ books.





http://c-faq.com/resources/books.html
Reply:The space is too small and time is too limited.





Please refer to the book: Complete Reference to C++ by Herbert Schildt.


No comments:

Post a Comment