TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ken H
NA
646
360.7k
An error occurred while initializing data members.
Dec 8 2013 1:02 AM
Hello friend,
I tried on a class member data error occurred while initializing.
System prompts an error message:error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
error C2143: syntax error : missing ';' before '}'
My codes is as follows:
#include<iostream>
using namespace std;
#define COURSE_NUM 4
class Student
{
public:
Student();
void ResetScore(int index,int new_score);
private:
float score[COURSE_NUM];
};
Student::Student(){
this->score[COURSE_NUM]={0.0}; // Attempting to initialize the array.
}
void Student::ResetScore(int index,int new_score)
{
this->score[index]=new_score;
}
int main()
{
Student stu;
stu.ResetScore(1,98.5);
return 1;
}
Thanks.
Reply
Answers (
4
)
How to output Greek letters commonly used in mathematics and
sort of structure in c language