'!' :绑定成员函数表达式的非法操作

时间:2015-11-28 20:27:05

标签: c++ class variables object

这是我的课程代码。我一直得到同样的错误。

'!' :对绑定成员函数的非法操作

#include <iostream>
#include <string>
#include <fstream>


#include "AMcore.h"
using namespace std;


int main (){


std::string filename1, filename2;

int plotPoint;

cout << "Amplitude Modulation Coursework" << endl;
cout << "Name: Mohammad Faizan Shah" << endl;
cout << "Student ID: 5526734 \n\n\n" << endl;

//AMcore obj1;

std::ifstream carrier(filename1);
cout << "Please enter the filename of the Carrier wave \n" << endl;
do{
    cin >> filename1;


    if (carrier.is_open)
    {
        cout << "file read succesfully... \n" << endl;
    }
    else if (!carrier.is_open)
    {
        cout << "file is not found!... Try carrier.txt...\n" << endl;

    }
} while (!carrier.is_open);

这是我的AMcore文件:     //功能定义     #包括     #include&#34; AMcore.h&#34;

AMcore::AMcore() {

std::string carrier  ;
std::string information ;

}            
AMcore::AMcore(string filename1, string filename2){
filename1 = carrier;
filename2 = information;

}

AMcore::~AMcore(){

}

string AMcore::getcarrier() const{
return carrier;


}

最后是我的AMcore.h(头文件)

   // Header -> Function Decleration

   #include <iostream>
   #include <string>

   using namespace std;

   #ifndef AMcore_h
   #define AMcore_h

    class AMcore{

    public:
    //defualt constructor
    string carrier;
    string information;
    AMcore();

    //overload constructor
    AMcore(string,string); 

    //destructor
    ~AMcore();

    //Accessor Functions
    string getcarrier() const;
    // returns name of txt file

    string getinformation() const;
    //returns name of txt file

0 个答案:

没有答案