I have main.cpp
我有main.cpp
#include "Customer.h"
#include "Driver.h"
int main(){
Customer o_customer; //Customer class object
//ManageMenu is a Driver.h method
ManageMenu( o_customer ); //calling method
return 0;
}
My Driver.h
is just a .h
and .cpp
file which does not have any class in it. What it does is handles all the screen display method, sample
我的Driver.h只是一个.h和.cpp文件,里面没有任何类。它的作用是处理所有的屏幕显示方法,样本
#include "Customer.h"
void ManageMenu( Customer & customer );
and, here is the issue , I am not able to pass the object reference in this function and I also believe that it is valid too as it simply means that we are passing the reference to some function.
并且,这是问题,我无法在此函数中传递对象引用,我也相信它也是有效的,因为它只是意味着我们将引用传递给某个函数。
My Driver.cpp
#include "Driver.h"
void ManageMenu( Customer & customer ){
//do something
//calls the method of Customer's class
customer.AddDetails();
}
I am not able to pass the object, the error which I am getting in g++
is
我无法传递该对象,我在g ++中遇到的错误是
error: variable or field 'ManageMenu' declared void
error: 'Customer' was not declared in this scope
'customer' was not declared in this scope
void ManageMenu( Customer & customer );
Please help me out and do explain me where I am doing the mistake. THANKS!!
请帮帮我解释一下我在做错的地方。谢谢!!
1 个解决方案
#1
0
In Driver.cpp you forgot to add
在Driver.cpp中你忘了添加
#include "Customer.h"
#1
0
In Driver.cpp you forgot to add
在Driver.cpp中你忘了添加
#include "Customer.h"