声明类实例 [英] Declaring Class Instances

查看:76
本文介绍了声明类实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!!我正在写一个关于课程的程序,我有一些问题。到目前为止,我的程序看起来像这样:

hello!! i am writing a program about classes and i have a few problems. my program so far looks like this:

展开 | 选择 | Wrap | 行号

推荐答案


你好!!我正在写一个关于课程的程序,我有一些问题。到目前为止,我的程序看起来像这样:

hello!! i am writing a program about classes and i have a few problems. my program so far looks like this:

展开 | 选择 | Wrap | 行号


我理解受保护的东西..这是与私人相同的事情?但我之前想说的(抱歉)是关于person1和person2以及main()中所有函数的使用。即将出现的错误只是关于他们未被宣布的错误。我会在哪里宣布他们 - 我虽然已经做了。以下是我更新的程序。如果你注意到setName函数的位置,我会厌倦几种方式,但它们确实是很长的错误。你知道怎么做吗?

well i understand the protected thing..isnt that the same thing as private?? but what i was trying to say before ( sorry about that) was about the person1 and person2 and all of the function uses within main (). the errors that are coming up are only about them not being declared. where would i declare them--i though i already did. and below is my updated program. if you notice where the setName function is, i tired a couple ways but they were really long errors. do you know how to do them?

展开 | 选择 | Wrap | 行号


$ b $我很了解受保护的东西..和私人一样的东西?但我之前想说的(抱歉)是关于person1和person2以及main()中所有函数的使用。即将出现的错误只是关于他们未被宣布的错误。我会在哪里宣布他们 - 我虽然已经做了。以下是我更新的程序。如果你注意到setName函数的位置,我会厌倦几种方式,但它们确实是很长的错误。你知道怎么做吗?


#include< iostream>

#include< fstream>

#include < iomanip>


使用命名空间std;


class学生

{

私人:

char姓氏[40];

char firstname [40];

char ID [10];

双倍GPA;

int分数;

公开:

学生(char [],char [],char [],双,int);

void showStudent();

void setName(char [],char []);

void setID(char [ ]);

int setGPA(double);

int setScore(int);

char getDecision();


};


int main()

{


返回0;

}



谢谢!!
well i understand the protected thing..isnt that the same thing as private?? but what i was trying to say before ( sorry about that) was about the person1 and person2 and all of the function uses within main (). the errors that are coming up are only about them not being declared. where would i declare them--i though i already did. and below is my updated program. if you notice where the setName function is, i tired a couple ways but they were really long errors. do you know how to do them?

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

class Student
{
private:
char lastname[40];
char firstname[40];
char ID[10];
double GPA;
int Score;
public:
Student(char [], char [], char [], double , int);
void showStudent();
void setName(char [], char []);
void setID(char []);
int setGPA(double );
int setScore(int );
char getDecision();

};

int main()
{

return 0;
}


thank you!!



哦,我想我明白了。你说的是showStudent();,你需要像这样指定对象:

Oohh, I think I got it. You are saying "showStudent();", you need to specify the object like this:

展开 | 选择 | Wrap | 行号


这篇关于声明类实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆