Posted: 11/28/2010 1:21:58 PM EDT
|
This is really just rant, so I apologize ahead of time.
I hate C++. I'm not sure I reallly like programming at all. My Algorithms/C++ class is really just a core class for me....my real interest lies in electrical/electronics. Until I came across this latest chapter I was able to soak it up pretty readily. Now, I'm studying classes and am totally lost. I am now 1 1/2 assignments behind with no hope of getting caught up. I often ask for help from my instructor(who is a programmer by trade) and usually wind up as lost as I began with. I'm sure there is some small subtlety that I'm just not getting. But, it's now getting to the point that even making an attempt seems futile as I stare a program that doesn't work and a compiler that loves to scream at me. Ok, enough with the whining. Thanks for the "listen". -D2V |
|
Oh man..
When I when I took the class it was just called C programming and the book was The C Bible by Kernighan and Ritchie, it was some time after that they started adding pluses to it. Make sure you get some Java classes, they would be more applicable for today. |
|
The assignment is this(due a week and a half ago..I have another due in two days that is VERY similar)...
www.msu.edu/~bowmanm/230/Program10.doc I set everything up as it should be (header, driver, function files) but I simply can't figure out how to assimilate all of the information in a manner that I can pass it into one "get" function. You wind up with three data types, floats, ints, and strings. So, I can call the data file, fill the arrays, etc. But, passing all of that data into my "get" function stumps me. If i do like: { for(i=0;i<n;i++0 id[i].get; first[i]get; last[i].get; etc,etc } The compiler gets really upset about that(since those declarations don't refer to classes). So, I have to figure out how to assimilate multiple data types into one array(say, student[i] so that I can call student[i].get in a loop), or figure out how to create [i] number of student classes and fill each with the appropriate id, first, last, age, gpa. Any suggestions? P.S. I used to be an honors student...I graduated with an associates in Automotive Technology and Electronics "Summa Cum Laude"....I am so freaking POed that I am behind in this class because the class stuff just absolutely boggles me. Something tells me I am missing something VERY simple here... Thanks for the help!! -D2V |
|
Quoted:
The assignment is this(due a week and a half ago..I have another due in two days that is VERY similar)... www.msu.edu/~bowmanm/230/Program10.doc I set everything up as it should be (header, driver, function files) but I simply can't figure out how to assimilate all of the information in a manner that I can pass it into one "get" function. You wind up with three data types, floats, ints, and strings. So, I can call the data file, fill the arrays, etc. But, passing all of that data into my "get" function stumps me. If i do like: { for(i=0;i<n;i++0 id[i].get; first[i]get; last[i].get; etc,etc } The compiler gets really upset about that(since those declarations don't refer to classes). So, I have to figure out how to assimilate multiple data types into one array(say, student[i] so that I can call student[i].get in a loop), or figure out how to create [i] number of student classes and fill each with the appropriate id, first, last, age, gpa. Any suggestions? P.S. I used to be an honors student...I graduated with an associates in Automotive Technology and Electronics "Summa Cum Laude"....I am so freaking POed that I am behind in this class because the class stuff just absolutely boggles me. Something tells me I am missing something VERY simple here... Thanks for the help!! -D2V First off –– do you *understand* classes and object oriented programming? You've got to declare a class, Student, that has private variables –– ID, last name, first name, age, and gpa. Inside this class, you need to declare methods –– a constructor, a get function and a put function, and all your operator overloads. It should look vaguely like this –– you'll need to check my syntax as I'm in the middle of a java class right now and don't have any reference materials with me: public class Student{ private int id; .. .. public Student(){ } public void get(ifstream inFile){ //do stuff to read from the file } public void put(ofstream outFile){ //do stuff to write to the file. } } Building the "get" and "put" functions the way he wants them done isn't something I've seen in an assignment before, but basically you need to pass an ifstream into the get method –– i.e. the get method needs to be something like: public void get(ifstream inFile){ //do stuff to read the data from the input stream } You're going to create multiple student objects –– an array of objects is fine, and you access them studentArray[i].get(cin <just for instance, you could also use a file here>), which needs to read each item (ID, firstname, lastname, age, and gpa) from the input stream for *that* object. First things first: Create your student class, as described above. Decide how many students you're going to need. Use the "new" operator to create new students. Use a for statement, generally, to do this –– just cycle through each element in the array and do something like studentArray[i] = new Student(); –– this creates a new student object at the array index i, and calls the default constructor to do it. Once this is done, cycle through the array again, this time calling the get method, as I described above. |
|
Joshki,
At one time...I thouht I understood the material. I've written several programs using classes without much trouble. What's got me here is how to pass the array information to my function file as a group(i.e. like id[i],age[i],first[i],last[i],gpa[i]) as one "clump" of information. That way, I can sort it and search thought it in another function. Since you can't make an array with different data types in it(like student[i] that contains all of the pertaining information for student number i) I can't figure out how to do so. Thanks for the input. I am going to read through your response a couple of more times and see what I can glean. Here is a copy of my header file: class students #define MAX 100 { public: students(); //Constructor-empty bool get(istream &); //Collects data from istream void put(ostream &); //Displays student data void operator > (students); //Last name greater than comparator void operator < (students); //Last name less than comparator void operator == (students); //Last name equality comparator bool operator == (int id); //Compares inputted ID to records private: string first,last; int id,age; float gpa; }; |
|
JBlitzen....here's a copy of the assignment:
Create a class that will store student information. The class will include ID, Name, Age and GPA in it. The name is comprised of First and Last Name. The actual data should be protected so that a program external to the class cannot access it directly. Along with the class, create input and output functions, to allow a name to be sent to/from a file, keyboard, or screen. Also, add functions to your class that will allow your array of students to be sorted. Your class should have the following elements: •ID •First name •Last name •Age •GPA •Constructor – initialize the data to be null. •Get function – takes one parameter, the input stream and reads the student information from it. •Put function - takes one parameter, the output stream. It displays the class data on the output stream. •>Last name is greater, or if last names are equal, first name is greater. •<Last name is lesser, or if last names are equal, first name is lesser. •==Last name is equal and First name is equal •==ID is equal to integer You will be able to download sample files from the web at: https://www.msu.edu/~bowmanm/230/List01.txt https://www.msu.edu/~bowmanm/230/List02.txt The main program should use an array of students. It will prompt the user for the file name, then read the student data into the array. There will be a maximum of 100 students in an input file. The program should display the contents of the array, sort the records, then display the sorted list. Memory Map Example Then the program should prompt the user for an ID, and search through the list for a match. If found, the student information should be displayed, otherwise a suitable message. The program should loop until the user enters 0. What to Hand In Hand in a copy of the code, and enough runs to demonstrate that your program and functions work with both the data files. |
|
Also, part of what gets me it this:
The assignment specifically dictates that I open/fill the array in the main(driver) program. No problem. But, basically what I have to do is this now: For(i=0;i<MAX(which is actually an established number using a count during my file opening transfer/code);i++) { ..... }... But during ..... I have to send a (id, first, last, gpa, age) for each student to a get function. But, the key is creating a different student(in the form of student[i]...I think) I think. This is part where I am totally lost. -D2V |
|
Got it.
You need to start by understanding that you won't have an array of ID's, and an array of Name's, and an array of GPA's. You'll have an array of students. student is a class that contains an ID, a Name, a GPA, etc. Just one of each. (Or however many are defined, maybe each student has a local GPA and a transfer credit GPA separate from it, or whatever.) "A" single student is just that: { student s; s.set_name("John", "Doe"); s.set_gpa(3.4); } A class can be used, generally, just like any basic data type, like an integer or a string. It's a data type that can contain other data types (including other classes). It's not rocket science. In fact, string is a class. It wraps a character array (eventually). class string { private: char data[255]; private: (overloaded = operator for assignment, like s = "john"; } (overloaded == operator for comparison, like if (s == "asdf") ... } (etc.) } Of course, STL's string is a lot more complicated than that, and the array is a dynamic one, but the concept is the same. All of that enables you to use "string" just like you'd use "int". string s = "john"; if (s == "asdf") { cout << "hey cool"; } int n = 3; if (n == 25) { cout << "hey cool"; } Without all the overhead of having to manipulate character arrays: char s[] = "john"; if (strcmp(s, "asdf") > 0) { cout << "hey cool"; } All you're doing with a class is "wrapping" functionality into a nice, easily used, package. That enables you to reuse the package without going nuts. Maybe the character array code doesn't scare you, but it would if you had 4,000 of them running around your first person shooter code. And what if you want a dynamically sized string? Now you're into really complex stuff, like 30 lines of code to do what I just did in 1 or 2. "student" has more than one data element. It has a GPA, a two part Name, and some other things. But they're all contained within it.
Once you understand that much, then the complicated stuff follows almost naturally. Class member functions are just things you can tell the object to do: student s; s.dance(); s.attend_a_new_class(); s.graduate(); s.date_D2Vs_sister(); And the class itself will compartmentalize the logic for each of those, so that, outside of the class, you just call the functions, rather than typing out all the lines of code each time that the functions encapsulate. Private, protected, and public, are just ways of protecting the things you've compartmentalized. Maybe someone using your class might be tempted to fuck with the GPA value directly, but they won't realize that every time the GPA is modified, you're adding the new value to a log file for that student, so that you can look back and see changes over time to his GPA. And so the new code doesn't do that, so you start seeing gaps in the GPA history of certain students, because some code is adding the log entries, and other code isn't. So, you set the GPA to private, so that the only way to modify it is to go through the class's "update_gpa" function, which does add the history record. And let me tell you, this isn't just about protecting your code from Fred Pakistani who's working on a fix to the student tracking software for extra credit. It's about you working on the same code three months from now, and forgetting about the history file, so you're the one who creates the gaps by modifying GPA directly. Yes, you can change the protection level of GPA to public, to work around the protection, but doing so will remind you that "hey, there was a reason I did that the first time, what was it?" And you look at the code and remember the history file, and all is right with the world. And constructors and overloaded operators just give you a way to make class behavior more implicit, and save a few keystrokes: student s = "John Doe"; student s2 = s; s2.set_gpa(3.2); if (s2 != s) { cout << "The GPA changed"); } else { cout << "The GPA did not change, or maybe my comparison function doesn't check GPA."; } It's all about encapsulation of other data types. Nothing more. If it weren't for just that, then there wouldn't be classes at all. Don't overthink them, all they do is hold other stuff, and provide a few techniques for more safely and implicitly controlling that stuff. |
|
Quoted:
Also, part of what gets me it this: The assignment specifically dictates that I open/fill the array in the main(driver) program. No problem. But, basically what I have to do is this now: For(i=0;i<MAX(which is actually an established number using a count during my file opening transfer/code);i++) { ..... }... But during ..... I have to send a (id, first, last, gpa, age) for each student to a get function. But, the key is creating a different student(in the form of student[i]...I think) I think. This is part where I am totally lost. -D2V Don't fill the whole array with students initially. Declare the array with a size of MAX, as you thought. Then have a file containing student names, ages, GPA's, whatever, ala: 1, John Doe, 3.1 2, Jane Doe, 2.1 3, D2 V, 4.0 etc., for about 30 or 40 students/lines. Then, in your main code, open the file. While there's data in it, iterate to the next open student array record (they're all open at first), and tell that one to populate itself to that line of the file. (Parsing input can be a science in itself, but I'll assume you've got a handle on it.) So, student_array[next_open_record].populate_from_line(input_file_line); // or whatever, you might prefer to read in one "word" at a time instead, so "populate_from_data(gpa, fname, lname);" etc. When you've looped through every line in the file, and told the appropriate student records to suck up the data in those lines, you now know how many records you filled in, and thus how many student records are still blank. If the file had 30 rows, then student_array has 30 elements with data, and 70ish with no data. To add a new student from, say, direct user input, have the user select a menu option to enter data, then call the appropriate "get_user_input" function for the first blank student_array record. That function will read in data from the input stream (after some prompts like "First name: ", etc.). On its own. The main function doesn't know or care how a student record is read in from keyboard input, only that it is in fact read in. This is not really how databases or whatever work, they use dynamic memory rather than fixed array sizes. But the concepts translate very well, so run with this for now. |
|
I had to read that a couple of times to really soak up what you are saying.
I completely understand what you are saying. In essence, by declaring a class(like "students") I am creating a new "object" which can contain multiple(and different) data types. That makes sense to me. In fact, I've been working operators that create new classes by doing basic modifiers(multiply, divide, add, etc.) and create new classes of them. However, every time I've had to do that(we have weekly lab assignments along with homework assignments) we have one data type(it was M+M candies last time..so my data type was int) and a set number of classes(like class candy a,b,c) My problem here is simple. While I don't want someone to write the code for me...can you suggest a way in which I can pass information to each student(my five data types) and create multiple students while doing so? I've tried declaring : class student[MAX]; in the beginning of my function..no dice. I am drawing a blank as to how to say to the compiler: "For student [i], pass in gpa[i], first[i],last [i], grade[i],age[i]" -D2V |
|
JBlitzen
Here is a copy of my overly simplistic driver code. /******************************* *Student Program *Written By Daren Baker *11-26-2010 *******************************/ #include<iostream> #include<iomanip> #include<string> #include<fstream> using namespace std; #include "students.h" //Main driver code void main() {string first[MAX],last[MAX],file; fstream a; int age[MAX],id[MAX],i,n; float gpa[MAX]; class students; //Header display cout << "Student Records Retriever" << endl; //Source file retrieval cout << "Enter source file name: "; cin >> file; //Open file a.open(file.data(),ios::in); //Intialize counter n = 0; //Gather student data from file while(!a.eof()&&a.good()) { a >> id[n] >> first[n] >> last[n] >> age[n] >> gpa[n]; n++; } //Send data to get function for(i=0;i<n-1;i++) I can, without any problems, fill my array with the incoming data from the opened file. I believe this is the way I have to do it, since the assignment specifically dictates I have to fill the array in the main driver code. Now, I just have to pass the information into my class to "fill" it. Can you recommend a way in which I can do so? I am trying to figure out a way to call get like: Student[i].get(a.file) so that get will in >> id in >> first in >> last in >> age in >> gpa Is this possible? -D2V(Daren, BTW |
|
Quoted:
JBlitzen Here is a copy of my overly simplistic driver code.
I can, without any problems, fill my array with the incoming data from the opened file. I believe this is the way I have to do it, since the assignment specifically dictates I have to fill the array in the main driver code. Now, I just have to pass the information into my class to "fill" it. Can you recommend a way in which I can do so? I am trying to figure out a way to call get like: Student[i].get(a.file) so that get will in >> id in >> first in >> last in >> age in >> gpa Is this possible? -D2V(Daren, BTW ugh I will. k, lemme look. |
|
On the 1st of January, 1998, Bjarne Stroustrup gave an interview to the IEEE's Computer magazine. Naturally, the editors thought he would be giving a retrospective view of seven years of object-oriented design, using the language he created. By the end of the interview, the interviewer got more than he had bargained for and, subsequently, the editor decided to suppress its contents, 'for the good of the industry' but, as with many of these things, there was a leak. Here is a complete transcript of what was was said, unedited, and unrehearsed, so it isn't as neat as planned interviews. You will find it interesting... Interviewer: Well, it's been a few years since you changed the world of software design, how does it feel, looking back? Stroustrup: Actually, I was thinking about those days, just before you arrived. Do you remember? Everyone was writing 'C' and, the trouble was, they were pretty damn good at it. Universities got pretty good at teaching it, too. They were turning out competent - I stress the word 'competent' - graduates at a phenomenal rate. That's what caused the problem. Interviewer: Problem? Interviewer: Of course, I did too Stroustrup: Well, in the beginning, these guys were like demi-gods. Their salaries were high, and they were treated like royalty. Interviewer: Those were the days, eh? Stroustrup: Right. So what happened? IBM got sick of it, and invested millions in training programmers, till they were a dime a dozen. Interviewer: That's why I got out. Salaries dropped within a year, to the point where being a journalist actually paid better. Stroustrup: Exactly. Well, the same happened with 'C' programmers. Interviewer: I see, but what's the point? Stroustrup: Well, one day, when I was sitting in my office, I thought of this little scheme, which would redress the balance a little. I thought 'I wonder what would happen, if there were a language so complicated, so difficult to learn, that nobody would ever be able to swamp the market with programmers? Actually, I got some of the ideas from X10, you know, X windows. That was such a bitch of a graphics system, that it only just ran on those Sun 3/60 things. They had all the ingredients for what I wanted. A really ridiculously complex syntax, obscure functions, and pseudo-OO structure. Even now, nobody writes raw X-windows code. Motif is the only way to go if you want to retain your sanity. Interviewer: You're kidding...? Stroustrup: Not a bit of it. In fact, there was another problem. Unix was written in 'C', which meant that any 'C' programmer could very easily become a systems programmer. Remember what a mainframe systems programmer used to earn? Interviewer: You bet I do, that's what I used to do. Stroustrup: OK, so this new language had to divorce itself from Unix, by hiding all the system calls that bound the two together so nicely. This would enable guys who only knew about DOS to earn a decent living too. Interviewer: I don't believe you said that... Stroustrup: Well, it's been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it's taken them a lot longer than I thought it would. Interviewer: So how exactly did you do it? Stroustrup: It was only supposed to be a joke, I never thought people would take the book seriously. Anyone with half a brain can see that object-oriented programming is counter-intuitive, illogical and inefficient. Interviewer: What? Stroustrup: And as for 're-useable code' - when did you ever hear of a company re-using its code? Interviewer: Well, never, actually, but... Stroustrup: There you are then. Mind you, a few tried, in the early days. There was this Oregon company - Mentor Graphics, I think they were called - really caught a cold trying to rewrite everything in C++ in about '90 or '91. I felt sorry for them really, but I thought people would learn from their mistakes. Interviewer: Obviously, they didn't? Stroustrup: Not in the slightest. Trouble is, most companies hush-up all their major blunders, and explaining a $30 million loss to the shareholders would have been difficult. Give them their due, though, they made it work in the end. Interviewer: They did? Well, there you are then, it proves O-O works. Stroustrup: Well, almost. The executable was so huge, it took five minutes to load, on an HP workstation, with 128MB of RAM. Then it ran like treacle. Actually, I thought this would be a major stumbling-block, and I'd get found out within a week, but nobody cared. Sun and HP were only too glad to sell enormously powerful boxes, with huge resources just to run trivial programs. You know, when we had our first C++ compiler, at AT&T, I compiled 'Hello World', and couldn't believe the size of the executable. 2.1MB Interviewer: What? Well, compilers have come a long way, since then. Stroustrup: They have? Try it on the latest version of g++ - you won't get much change out of half a megabyte. Also, there are several quite recent examples for you, from all over the world. British Telecom had a major disaster on their hands but, luckily, managed to scrap the whole thing and start again. They were luckier than Australian Telecom. Now I hear that Siemens is building a dinosaur, and getting more and more worried as the size of the hardware gets bigger, to accommodate the executables. Isn't multiple inheritance a joy? Interviewer: Yes, but C++ is basically a sound language. Stroustrup: You really believe that, don't you? Have you ever sat down and worked on a C++ project? Here's what happens: First, I've put in enough pitfalls to make sure that only the most trivial projects will work first time. Take operator overloading. At the end of the project, almost every module has it, usually, because guys feel they really should do it, as it was in their training course. The same operator then means something totally different in every module. Try pulling that lot together, when you have a hundred or so modules. And as for data hiding. God, I sometimes can't help laughing when I hear about the problems companies have making their modules talk to each other. I think the word 'synergistic' was specially invented to twist the knife in a project manager's ribs. Interviewer: I have to say, I'm beginning to be quite appalled at all this. You say you did it to raise programmers' salaries? That's obscene. Stroustrup: Not really. Everyone has a choice. I didn't expect the thing to get so much out of hand. Anyway, I basically succeeded. C++ is dying off now, but programmers still get high salaries - especially those poor devils who have to maintain all this crap. You do realise, it's impossible to maintain a large C++ software module if you didn't actually write it? Interviewer: How come? Stroustrup: You are out of touch, aren't you? Remember the typedef? Interviewer: Yes, of course. Stroustrup: Remember how long it took to grope through the header files only to find that 'RoofRaised' was a double precision number? Well, imagine how long it takes to find all the implicit typedefs in all the Classes in a major project. Interviewer: So how do you reckon you've succeeded? Stroustrup: Remember the length of the average-sized 'C' project? About 6 months. Not nearly long enough for a guy with a wife and kids to earn enough to have a decent standard of living. Take the same project, design it in C++ and what do you get? I'll tell you. One to two years. Isn't that great? All that job security, just through one mistake of judgement. And another thing. The universities haven't been teaching 'C' for such a long time, there's now a shortage of decent 'C' programmers. Especially those who know anything about Unix systems programming. How many guys would know what to do with 'malloc', when they've used 'new' all these years - and never bothered to check the return code. In fact, most C++ programmers throw away their return codes. Whatever happened to good ol' '-1'? At least you knew you had an error, without bogging the thing down in all that 'throw' 'catch' 'try' stuff. Interviewer: But, surely, inheritance does save a lot of time? Stroustrup: Does it? Have you ever noticed the difference between a 'C' project plan, and a C++ project plan? The planning stage for a C++ project is three times as long. Precisely to make sure that everything which should be inherited is, and what shouldn't isn't. Then, they still get it wrong. Whoever heard of memory leaks in a 'C' program? Now finding them is a major industry. Most companies give up, and send the product out, knowing it leaks like a sieve, simply to avoid the expense of tracking them all down. Interviewer: There are tools... Stroustrup: Most of which were written in C++. Interviewer: If we publish this, you'll probably get lynched, you do realise that? Stroustrup: I doubt it. As I said, C++ is way past its peak now, and no company in its right mind would start a C++ project without a pilot trial. That should convince them that it's the road to disaster. If not, they deserve all they get. You know, I tried to convince Dennis Ritchie to rewrite Unix in C++. Interviewer: Oh my God. What did he say? Stroustrup: Well, luckily, he has a good sense of humor. I think both he and Brian figured out what I was doing, in the early days, but never let on. He said he'd help me write a C++ version of DOS, if I was interested. Interviewer: Were you? Stroustrup: Actually, I did write DOS in C++, I'll give you a demo when we're through. I have it running on a Sparc 20 in the computer room. Goes like a rocket on 4 CPU's, and only takes up 70 megs of disk. Interviewer: What's it like on a PC? Stroustrup: Now you're kidding. Haven't you ever seen Windows '95? I think of that as my biggest success. Nearly blew the game before I was ready, though. Interviewer: You know, that idea of a Unix++ has really got me thinking. Somewhere out there, there's a guy going to try it. Stroustrup: Not after they read this interview. Interviewer: I'm sorry, but I don't see us being able to publish any of this. Stroustrup: But it's the story of the century. I only want to be remembered by my fellow programmers, for what I've done for them. You know how much a C++ guy can get these days? Interviewer: Last I heard, a really top guy is worth $70 - $80 an hour. Stroustrup: See? And I bet he earns it. Keeping track of all the gotchas I put into C++ is no easy job. And, as I said before, every C++ programmer feels bound by some mystic promise to use every damn element of the language on every project. Actually, that really annoys me sometimes, even though it serves my original purpose. I almost like the language after all this time. Interviewer: You mean you didn't before? Stroustrup: Hated it. It even looks clumsy, don't you agree? But when the book royalties started to come in... well, you get the picture. Interviewer: Just a minute. What about references? You must admit, you improved on 'C' pointers. Stroustrup: Hmm. I've always wondered about that. Originally, I thought I had. Then, one day I was discussing this with a guy who'd written C++ from the beginning. He said he could never remember whether his variables were referenced or dereferenced, so he always used pointers. He said the little asterisk always reminded him. Interviewer: Well, at this point, I usually say 'thank you very much' but it hardly seems adequate. Stroustrup: Promise me you'll publish this. My conscience is getting the better of me these days. Interviewer: I'll let you know, but I think I know what my editor will say. Stroustrup: Who'd believe it anyway? Although, can you send me a copy of that tape? Interviewer: I can do that. |
|
Okay.
THE ONLY ARRAY YOU NEED IS STUDENTS. That's it. You do not need or want an array of names, GPA's, or anything else in the main code. Just students. Each element in students is... a student. To read in GPA or whatever for a student, you do that WITHIN the student class. Not in main. Each student knows how to read its own data in. Even if that weren't the case, you'd only need temporary holders for GPA and such, ala:
But you don't. Now, each student doesn't need an array, either. Each student only has one GPA, only one first name, etc. So, really, the only array in your entire program should be: student student_array[MAX]; (Or whatever you choose to call it.) That's it. Everything else will take care of itself. In fact, that sentence is the whole beauty of classes. They take care of themselves. |
|
Also, per your IM (you're welcome), an array is NOT a data type.
A class is a custom data type. int is a basic data type. char is a basic data type. student is a custom data type. string is a standard data type. An array is just a collection of data types stored next to one another in memory. Consider that there is no "array" keyword in C++. You can't say: array a; "array" is just a concept, not a data type. "student" IS a data type, ONCE you define it to be. "int" is a data type, because it's built in. "string" is a data type, because it's defined to be so in the standard template library. It's built out of basic data types, but you'd never know unless you looked. |
|
Sweet Jesus...I just figured it out!!
If I could only begin to tell you how many hours I've wasted of my life staring at this assignment. The fucking assignment even states it(somehow, after reading it oh, thirty times or so, I missed that)..I only need one array: students. I am wasting my time setting up all of these arrays. I just need ONE array: Students. Wow.
-D2V JBlitzen, If you were somewhere near me...I'd buy you an ice-cold beer. |
|
I came in late to this, but suffice to say, you're going to need to get used to classes, and objects, operator overloading, and lots of other fun shit as even as an EE, you're going to find C++ and SystemC encroaching on your world. <= gate basher, P-well and N-Well drawer, schematic jihadi, and Verilog bigot. |
|
JBlitzen,
Yup, I sure did. I'd have never figured it out without your help, though. I was later having some problems comparing calling operator functions (x > a.x) but figure that out as well. I am now charged with creating another class/function file that will modify my sorting of classes as well as add and remove classes. Oh boy!! -D2V |