亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

error C2659: “=”: 作為左操作數 ?

//Person.h

#ifndef PERSON_H
#define PERSON_H

#include <string>
using namespace std;

class Person
{
public:
?? ?Person(string name);
?? ?virtual void work()=0;//純虛函數
?? ?virtual ~Person(){}
private:
?? ?string m_strName;
};

#endif

//Worker.h

#ifndef WORKER_H
#define WOEKER_H

#include "Person.h"
class Worker:public Person
{
public:
?? ?Worker(string name,int age);
?? ?//virtual void work();
private:
?? ?int m_iAge();
};

#endif

//Worker.cpp

#include <iostream>
#include "Worker.h"
using namespace std;

Worker::Worker(string name,int age):Person(name)
{
?? ?m_iAge = age;//錯誤1
}

//void Worker::work()
//{
//?? ?cout<<"work()"<<endl;
//}


錯誤?? ?1?? ?error C2659: “=”: 作為左操作數?? ?c:\users\administrator\documents\visual studio 2012\projects\consoleapplication39\consoleapplication39\worker.cpp?? ?7?? ?1?? ?ConsoleApplication39


正在回答

1 回答

private:
?? ?int m_iAge();

你定義的是一個成員函數;調用的時候卻當成成員變量使用。

應該把那個括號去掉就可以了?!?/p>

private:
?? ?int m_iAge;

2 回復 有任何疑惑可以回復我~
#1

慕粉3168680 提問者

謝謝!
2017-04-07 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
C++遠征之多態篇
  • 參與學習       66224    人
  • 解答問題       334    個

本教程將帶領大家體會面向對象三大特性中的多態特性

進入課程

error C2659: “=”: 作為左操作數 ?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號