Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am new in CPP. very confused between declaration and defination of function.
here is my code
file name: pcanlinkerclass.cpp
C#
pCANLinkerClass::pCANLinkerClass()
{
    LoadAPI();
}



void pCANLinkerClass::LoadAPI()

{
    mypcanlinkerfunction();
    qDebug() << "first message";

}

void pCANLinkerClass::mypcanlinkerfunction()
{
    qDebug() << "second message";
}

giving me error "mypcanlinkerfunction" not declared in the scope.

I dont know whats wrong with this code? and how to make it functional.
any help would be appreciated please.
Posted
Updated 30-Oct-15 0:59am
v2
Comments
Richard MacCutchan 30-Oct-15 7:14am    
Where is the class declaration of pCANLinkerClass?
Ramiien 30-Oct-15 9:34am    
i did in .h file
Richard MacCutchan 30-Oct-15 12:24pm    
And you think we can somehow read that?

1 solution

There must be a method with the same name and signature in the pCANLinkerClass class declaration (usually in the header file), e.g.
in pCANLinkerClass header file
C++
class pCANLinkerClass
{
//...
  void mypcanlinkerfunction();
//...
};
 
Share this answer
 
v4
Comments
Ramiien 30-Oct-15 7:14am    
Thanks bro
CPallini 30-Oct-15 7:18am    
You are welcome.
ridoy 30-Oct-15 9:05am    
(y)
Ramiien 30-Oct-15 9:05am    
I have one question for my clarification only
I need to list all functions of pcanlinkerclass.cpp into header file of the class??
class pCANLinkerClass
{
//...
void func1();
void func2();
void func3();
void func4();
//...
};
or is there some better way to manage these??
CPallini 30-Oct-15 9:06am    
Yes, this is the way C++ works. There is no 'better way'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900