我的学生班的实例帮助!! [英] instances of my student class help!!
问题描述
你好,新发帖,在c ++中遇到了困境。我似乎无法创建我的学生班级的新
实例。我的想法是创建一个数据库,其中用户输入姓氏和图书馆卡号等。
代码我无法编译的是:
...... void main(){
for(int i = 0; i< 10; i ++){
学生[i];
cout<< 输入学生姓氏: << endl;
cin>> c;
s [i] .setSurname(c);
}
}
多数民众赞成基地!!如果有人可以帮我直接发送电子邮件
ki ******** @ hotmail.com 或回复小组!!!
我真的需要帮助请帮助!!
Kirk。
Hello, new to posting, got a dilema in c++. I cant seem to create new
instances of my student class. The idea is to make a database where
the user inputs surnames and library card numbers etc. The piece of
code I cant get to compile is:
......void main() {
for (int i=0; i<10; i++) {
student s[i];
cout << "Enter student surname: " << endl;
cin >> c;
s[i].setSurname(c);
}
}
Thats the bases!! If anyone can help me pls email direct
ki********@hotmail.com or reply on the group!!!
I really really need help pls!!
Kirk.
推荐答案
Kirk Bevins写道:
Kirk Bevins wrote:
你好,新发帖,在c ++中遇到了困境。我似乎无法创建我的学生班级的新实例。这个想法是建立一个数据库,用户输入姓氏和图书馆卡号等。我不能编译的代码是:
..... void main(){
int main()
main()应该总是返回int,其他任何东西都可能导致未指定
结果。
for(int i = 0; i< 10; i ++){
student s [i];
Hello, new to posting, got a dilema in c++. I cant seem to create new
instances of my student class. The idea is to make a database where
the user inputs surnames and library card numbers etc. The piece of
code I cant get to compile is:
.....void main() {
int main()
main() should always return int, anything else might cause unspecified
results.
for (int i=0; i<10; i++) {
student s[i];
你到底想要做什么?也许你想要
之类的东西(假设学生是班级名字):
std :: vector< student>学生们; //你需要#include< vector>
for(unsigned int i = 0; i< 10; i ++)
{
学生; //如果需要,添加构造函数参数。
students.push_back(s)
}
s [0] .setSurname(" ;无论是什么");
What exactly are you trying to do here? Perhaps you would like to have
something like (assuming student is the class name):
std::vector<student> students; // You need #include <vector>
for( unsigned int i = 0; i < 10; i++ )
{
student s; // Add contructor parameters if needed.
students.push_back( s )
}
s[0].setSurname( "whatever" );
" Kirk Bevins" <き******** @ hotmail.com>在消息中写道
新闻:1d ************************** @ posting.google.c om ...
"Kirk Bevins" <ki********@hotmail.com> wrote in message
news:1d**************************@posting.google.c om...
你好,新发帖,在c ++中遇到了困境。我似乎无法创建我的学生班级的新实例。这个想法是建立一个数据库,用户输入姓氏和图书馆卡号等。我不能编译的代码是:
..... void main(){
for(int i = 0; i< 10; i ++){
student s [i];
反转那些:
学生[10];
for(int i = 0; i< ; 10; ++ i){
cout<< 输入学生姓氏: << endl;
cin>> c;
s [i] .setSurname(c);
}
}
这就是基础!!如果有人可以帮我直接发送电子邮件
ki ******** @ hotmail.com 或回复小组!!!
我真的需要帮助!!
Kirk。
Hello, new to posting, got a dilema in c++. I cant seem to create new
instances of my student class. The idea is to make a database where
the user inputs surnames and library card numbers etc. The piece of
code I cant get to compile is:
.....void main() {
for (int i=0; i<10; i++) {
student s[i];
Reverse those:
student s[10];
for (int i = 0; i < 10; ++i) {
cout << "Enter student surname: " << endl;
cin >> c;
s[i].setSurname(c);
}
}
Thats the bases!! If anyone can help me pls email direct
ki********@hotmail.com or reply on the group!!!
I really really need help pls!!
Kirk.
>
Thanx的帮助!!我似乎在c ++上毫无用处,即使我需要这样做也不需要它来支付它!
我的下一个问题是我无法响应用户输入来创建一定数量的
学生实例:
我有:
cout<< 你想加几个学生?在
100"下输入一个数字。 << endl;
cin>> f;
学生[f];
for(int i = 0; i< f; i ++){
无法编译! :(
非常感谢任何帮助。
" Howard"< al ***** @ hotmail .com>在消息新闻中写道:< bthqs5>> ..... void main(){
Thanx for the help!! I seem to be useless at c++ even tho I need to do
it!
My next problem is I cant respond to user input to create an amount of
student instances:
I have:
cout << "How many students would you like to add? Enter a number under
100" << endl;
cin >> f;
student student[f];
for (int i=0; i<f; i++) {
Can''t seem to compile! :(
Would appreciate any help pls.
"Howard" <al*****@hotmail.com> wrote in message news:<bthqs5> > .....void main() {
for(int i = 0 ; i< 10; i ++){
学生[i];
for (int i=0; i<10; i++) {
student s[i];
反转那些:
学生[10]; > for(int i = 0; i< 10; ++ i){
Reverse those:
student s[10];
for (int i = 0; i < 10; ++i) {
cout<<"输入学生姓氏:"<< ; endl;
cin>> c;
s [i] .setSurname(c);
}
cout << "Enter student surname: " << endl;
cin >> c;
s[i].setSurname(c);
}
这篇关于我的学生班的实例帮助!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!