Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,153,511 members, 7,819,842 topics. Date: Tuesday, 07 May 2024 at 02:35 AM |
Nairaland Forum / Science/Technology / Programming / C++ Assignment Help Kobojunkie, Duela, Anyone (802 Views)
[Assignment Help] A Company Selling Cds And Dvds / Java Proramers:java Assignment: Can Someone Help Provide A Solution To This / Hotel Booking And Reservation Assignment For A 200level Student (c++). (2) (3) (4)
C++ Assignment Help Kobojunkie, Duela, Anyone by solomon201(m): 7:15am On Jun 24, 2010 |
I am having problems compiling this code. first I used arrays in place if vectors but the problem is still there. when i try to compile it tells me "Linker Error undefined reference to record::record() I am using Dev Cpp as my compiler. Pls guys take a look at it and tell we what is wrong. #include<iostream> #include<vector> #include<fstream> #include<string> using namespace std; class record { private: string name; vector<int>score; int total; double average; int settotal() { int temp=0; for(int index=0;index<score.size();index++) temp+=score[index]; return temp; } double setaverage() {return (total/score.size());} public: record(); void setdata(string n, vector<int>data) {name=n; score.resize(data.size()); for(int k=0;k<data.size();k++) score[k]=data[k];} void display() { cout<<name<<" "; for(int t=0;t<score.size();t++) cout<<score[t]<<" "; } }; int main() { record people; ifstream readfile; readfile.open("test.txt" string tname; vector<int>tdata; tdata.resize(3); readfile>>tname; { for(int index=0;index<tdata.size();index++) readfile>>tdata[index]; } people.setdata(tname,tdata); return 0; } As I said earlier I have tried using arrays in place of vectors but I get the same error. what I am trying to do is read data from a text file, compute total and average then display all the data; Your help will greatly be appreciated. |
Re: C++ Assignment Help Kobojunkie, Duela, Anyone by sweetpawn2: 12:36pm On Jun 24, 2010 |
Read a line from the file store the value in a variable say x add x to a variable called sum: sum = sum + x also create var n and add 1 to n: n = n +1 Repeat the steps above until the end of the file is reached Now divide sum by n to get average. |
Re: C++ Assignment Help Kobojunkie, Duela, Anyone by sweetpawn2: 12:36pm On Jun 24, 2010 |
Read a line from the file store the value in a variable say x add x to a variable called sum: sum = sum + x also create var n and add 1 to n: n = n +1 Repeat the steps above until the end of the file is reached Now divide sum by n to get average. |
Re: C++ Assignment Help Kobojunkie, Duela, Anyone by solomon201(m): 2:36pm On Jun 24, 2010 |
each line contains name, score1, score2, score3; something like this: Mike 70 80 66 Chike 65 85 70 I want to be able to find the student who has the highest score in a certain course that is why I used a vector to hold the scores; I think the problem is with my display function not so sure because when i removed the call to the function and compiled, the program compiled. pls take a look at it again. Thanks |
Re: C++ Assignment Help Kobojunkie, Duela, Anyone by IbrahimB: 12:43am On Jun 30, 2010 |
Replace the line record(); in your class definition with record(){}; - that should solve your problem. |
(1) (Reply)
What Can I Do With Gis? / Please Suggest Project Topic For Turkish-Trained Nigerian / Need Help With Service That Can Process Text Messages
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12 |