| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 418 人关注过本帖
标题:语法错误
只看楼主 加入收藏
vx0532
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2012-8-22
结帖率:0
收藏
 问题点数:0 回复次数:3 
语法错误
#include<iostream>
using namespace std;
class Vehicle
{
public:
    Vehicle(float speed=0,int total=0)
    {
        Vehicle::speed=speed;
        Vehicle::total=total;
    }
protected:
    float speed;
    int total;
};
class  Motor
{
public:
    Motor(char*motor)
    {
        Motor::motortype=motor;
    }
    char* SMT(Motor &temp);
protected:
    char* motortype;
};
char* Motor::SMT(Motor &temp)
{
        return temp.motortype;
}
 
class Car:public Vehicle
{
public:
    Car(float speed,int total,int aird,char* mototype):Vehicle(speed,total),motor(motortype)
    {
        Car::aird=aird;
    }
 
    Motor rm(Car &temp);
protected:
    int aird;
    Motor motor;
};
Motor Car::rm(Car &temp)
{
    return temp.motor;
}
void test101(Vehicle &temp)
{
};
void test102(Motor &temp)
{
    cout<<temp.SMT(temp);
}
 
void test24()
{
    Car a(150,4,250,"奥地利AVL V8");
    test101(a);
    test102(a.rm(a));
}

上述代码是一个教程上的例子,但是提示有语法问题,是在第34行,提示:“motorytpye”没有定义。
 请问应该如何修改?
 谢谢!
搜索更多相关主题的帖子: total public include return motor 
2012-11-29 15:25
ltianc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:56
专家分:128
注 册:2012-10-16
收藏
得分:0 
你这是c++语言,我只懂c。

世界等我去改变。
2012-11-29 16:04
lxsjzbd
Rank: 4
来 自:河北省
等 级:业余侠客
帖 子:97
专家分:258
注 册:2012-3-31
收藏
得分:0 
你的参数是mototype
2012-11-29 16:09
vx0532
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2012-8-22
收藏
得分:0 
谢谢!
2012-11-29 16:14
快速回复:语法错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030468 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved