我有这个:
#ifndef APPLICATION_H
#define APPLICATION_H
#include "UserOpinion.h"
#include "ApplicationConstructor.h"
#include <vector>
using namespace std;
class Application{
public:
Application(char *, string, string, ApplicationConstructor &, float); //Application's Constructor
Application(const Application &); //Copy Constructor
virtual void ShowData() const = 0; //Virtual ShowData() Method)
virtual ~Application(); //Destructor
bool operator== (const Application &) const; //Overload the == operator, this case overloads and the case of != operator
vector<ApplicationConstructor> getApplicationConstructorVector(); //Get the Application Constructor Vector
vector<UserOpinion> getUserOpinionVector(); //Get the User Opinion Vector
void setApplicationConstructorVector(vector<ApplicationConstructor> &); //Set the Application Constructor Vector
void setUserOpinionVector(vector<UserOpinion> &); //Set the User Opinion Vector
protected:
char *ApplicationCode;
string ApplicationName;
string ApplicationVersion;
float Price;
ApplicationConstructor &ApplicationConstructor;
UserOpinion *UserView;
vector<ApplicationConstructor> &ApplicationConstructorVector; // Vector with Application Constructor Objects
vector<UserOpinion> &UserOpinionVector; // Vector pointer to User Opinion Objects
};
#endif /* APPLICATION_H */
还有这个:
#ifndef APPLICATIONCONSTRUCTOR_H
#define APPLICATIONCONSTRUCTOR_H
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
class ApplicationConstructor{
private:
string ConstructorCode; //Constructor's code
char *ConstructorName; //Constructor's name
string ConstructorEmail; //Constructor's email
public:
ApplicationConstructor(string, char *, string); //Constructor
ApplicationConstructor(const ApplicationConstructor&); //Copy constructor
void setConstructorCode(string); //Set the constructor's code
void setConstructorName(char *); //Set the constructor's name
void setConstructorEmail(string); //Set the constructor's email
string getConstructorCode(); //Get the constructor's code
string getConstructorEmail(); //Get the constructor's email
char *getConstructorName(); //Get the constructor's name
bool operator== (const ApplicationConstructor &) const; //Overloading the == operator for the ApplicationConstructor class
bool operator= (const ApplicationConstructor &); //Overloading the = operator for the ApplicationConstructor class
void showData(); //Show the Application Constructor Data Method
virtual ~ApplicationConstructor(); //Destructor
};
#endif /* APPLICATIONCONSTRUCTOR_H */
我得到以下信息:
In file included from Application.cpp:8:0:
Application.h:55:15: error: invalid use of non-static data member 'Application::ApplicationConstructor'
vector<ApplicationConstructor> &ApplicationConstructorVector; // Vector with Application Constructor Objects
^~~~~~~~~~~~~~~~~~~~~~
Application.h:53:32: note: declared here
ApplicationConstructor &ApplicationConstructor;
^~~~~~~~~~~~~~~~~~~~~~
Application.h:55:15: error: invalid use of non-static data member 'Application::ApplicationConstructor'
vector<ApplicationConstructor> &ApplicationConstructorVector; // Vector with Application Constructor Objects
^~~~~~~~~~~~~~~~~~~~~~
Application.h:53:32: note: declared here
ApplicationConstructor &ApplicationConstructor;
^~~~~~~~~~~~~~~~~~~~~~
Application.h:55:15: error: invalid use of non-static data member 'Application::ApplicationConstructor'
vector<ApplicationConstructor> &ApplicationConstructorVector; // Vector with Application Constructor Objects
^~~~~~~~~~~~~~~~~~~~~~
Application.h:53:32: note: declared here
ApplicationConstructor &ApplicationConstructor;
有任何建议吗?该程序运行得很好。.我认为const值正在发生某些事情,它在Application.h的第一行和vector处标记为红色。请提出任何建议?
似乎不是将数据成员声明为引用,例如这样
vector<UserOpinion> &UserOpinionVector; // Vector pointer to User Opinion Objects
您的意思是指针的声明,例如
vector<UserOpinion> *UserOpinionVector; // Vector pointer to User Opinion Objects