Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualcozzie

Posted 21 June 2013 - 01:50 PM

Thanks, I didn't know that.

So to be sure, this would be correct:

class MyClass

{
public:
   int mAge;

   void DoSometingWithNoneMembers(const float p1, float *p2) const;
   void UpdateAge(const int &pAge);
}

void MyClass::DoSometingWithNoneMembers(const float p1, float *p2)

{
   p2 = p1;
}

void MyClass:UpdateAge(const int &pAge)
{
   mAge = *pAge;
}

Where I assume that the 'const' keyword for member functions is only needed in the prototype.

Is this correct, or does is also have to be in the implementation? (sounds logical for readability if it's also there)


#2cozzie

Posted 21 June 2013 - 01:49 PM

Thanks, I didn't know that.

So to be sure, this would be correct:

class MyClass

{
public:
   int mAge;

   void DoSometingWithNoneMembers(const float p1, float *p2) const;
   void UpdateAge(const int pAge);
}

void MyClass::DoSometingWithNoneMembers(const float p1, float *p2)

{
   p2 = p1;
}

void MyClass:UpdateAge(const int pAge)
{
   mAge = pAge;
}

Where I assume that the 'const' keyword for member functions is only needed in the prototype.

Is this correct, or does is also have to be in the implementation? (sounds logical for readability if it's also there)


#1cozzie

Posted 21 June 2013 - 01:47 PM

Thanks, I didn't no that.

So to be sure, this would be correct:

 

class MyClass

{

   int mAge;

 

   void DoSometingWithNoneMembers(const float p1, float *p2) const;

}

 

void MyClass::DoSometingWithNoneMembers(const float p1, float *p2)

{

   p2 = p1;

}


PARTNERS