[–] [deleted] 0 points 2 points (+2|-0) ago  (edited ago)

[Deleted]

0
2

[–] Rainy-Day-Dream [S] 0 points 2 points (+2|-0) ago 

this got it to work thanks

0
0

[–] Norm 0 points 0 points (+0|-0) ago 

It's similar to how you're using "using namespace std" if you didn't have that, you'd have to use std::cin, std::cout, etc because all those are in the std namespace, and all classes have their own namespace, so declaring the struct inside the class requires the namespace.

so when making class methods when you use ClassName:: in front of the method, you're using it's namespace so you don't have do use the namespace in front of all the classes variables and other methods.

0
0

[–] Omnipresent 0 points 0 points (+0|-0) ago 

Damn it I was just about to say that.

1
1

[–] antiracist 1 points 1 points (+2|-1) ago 

You actually suck dick.

@eagleshigh @sarmegahhikkitha @bojangles

0
0

[–] Rainy-Day-Dream [S] 0 points 0 points (+0|-0) ago 

at least I enjoy it, you just do it for shekels

1
1

[–] antiracist 1 points 1 points (+2|-1) ago 

Nuh uh, I don't suck dick. You do.

@eagleshigh @sarmegahhikkitha @bojangles

0
0

[–] Omnipresent 0 points 0 points (+0|-0) ago 

Just a question, but why did you declare a Data class? If I am understanding your intentions, why didn't you just make a studentType class with the member functions in Data put into this studentType class instead, and the current struct's variables as this class's member variables?

Will you ever need to declare a Data object by itself, in your ultimate project?


class studentType {

public:

//All the relevant member variables
string name;

int ID; 

int average;

char grade;

...
 //All the relevant member functions
void calcAverage(int x, int y, int z) { .... average = varThatHoldsAverage; }

void calcGrade(float x) { .... grade = varThatHoldsGrade; }

...

....

};

studentType newStudent; //Declare an object

newStudent.input(); //Call a member function on object

newStudent.calcAverage(100,90,95); //Update the 'average' member variable of object newStudent with new data

cout << newStudent.name << endl; //access and output a public member variable of the object


I am just curious as to why you chose to implement it that way.

2
-1

[–] tomlinas 2 points -1 points (+1|-2) ago 

Disclaimer: I've only futzed around in C++, I'm a C# guy.

Pretty sure you don't need line 79 at all, when you instantiate an object from your class it should come prepopulated with its members. Instead, line 80 should read

Info.newStudent = Info.Input();

As an aside, Data is kind of a crappy name for an object...I don't know exactly what it is, but this class looks like it's either meant to bea gradebook or a student. I suspect you may be hoping to make one copy of this class and instantiate multiple structs, each representing a student -- if you want to do that, the student struct definition should really be seperate from the gradebook class.

0
1

[–] Omnipresent 0 points 1 points (+1|-0) ago 

I made the same assumption, but that didn't work because studentType isn't actually a member variable to the Data class, but just a definition of a type (that can be accessed using the scope resolution operator). I didn't see that until I opened up my laptop and actually ran the code myself.

1
-1

[–] SwiftLion 1 points -1 points (+0|-1) ago 

Shouldn’t it be “Data.StudentType”?

0
0

[–] Rainy-Day-Dream [S] 0 points 0 points (+0|-0) ago 

Data is the class and info is the object, do I not need an object for structures?

0
0

[–] tomlinas 0 points 0 points (+0|-0) ago 

Structures are objects.

0
0

[–] roznak 0 points 0 points (+0|-0) ago 

It should be Data.StudentType.

You defined a "structure" StudentType inside a class. You can't create an object and use that object as a type definition.

1
-1

[–] Clem_Fister 1 points -1 points (+0|-1) ago  (edited ago)

You are not "aware" of newStudent. You need to declare you variable as StudentType.

(Sorry, im on ipad. Can't back and forth to the code so easily.)

0
0

[–] Rainy-Day-Dream [S] 0 points 0 points (+0|-0) ago 

isn't that what I'm doing on that line? declaring the variable?

0
0

[–] Clem_Fister 0 points 0 points (+0|-0) ago 

Ignore my comment. IPad. Also, haven't coded in 18 years. :)

2
-2

[–] Omnipresent 2 points -2 points (+0|-2) ago 

Uhh, Why not...

Info.studentType = Info.input(); , deleting line 79 declaration entirely?

0
0

[–] Rainy-Day-Dream [S] 0 points 0 points (+0|-0) ago 

what do I put behind the "." for the variables that come after that then

0
0

[–] Omnipresent 0 points 0 points (+0|-0) ago 

I suppose if you want the name of the student, we do Info.studentType.name?