开发者

How to call a non-member function that takes in an object within a method

开发者 https://www.devze.com 2023-03-01 01:43 出处:网络
Say I have a class Student, and I have already declared a non-member function called \"function_A\" that takes in as an a开发者_C百科rgument, type Student.

Say I have a class Student, and I have already declared a non-member function called "function_A" that takes in as an a开发者_C百科rgument, type Student.

Now say INSIDE the Student class, I had a member function, and in it, I wanted to reference the non-member function, "function_A", declared earlier. What would I pass in as the argument (the argument itself must be type Student).

code


Do you mean something like this?

void function_A(Student s);

class Student { 
   void function_A() {
        ::function_A(*this);
   }

if the member function's name is different than function_A, I can't see any problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消