Simple Class: Path of execution.
May 31, 2013 at 11:30am UTC
I'm teaching myself about Classes so i can start using SFML, But
Cant work out how the function at line 14 is called.
Can someone explain the logical path of this program during execution?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <iostream>
class FullName
{
private :
std::string a;
std::string b;
std::string c;
public :
FullName (std::string, std::string, std::string);
std::string All(){return a + b + c;}
};
FullName::FullName(std::string x, std::string y, std::string z)
{
a = x;
b = y;
c = z;
}
int main()
{
FullName FNVar("My" ,"Full" ,"Nane" );
std::cout << FNVar.All();
}
May 31, 2013 at 11:34am UTC
the function on line 14 is called constructor. You call the constructor only when the object is constructed (on line 23)
May 31, 2013 at 2:06pm UTC
Thank's coder777.
Topic archived. No new replies allowed.