The clever person who help me :)

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 21
Reputation: CE Student is an unknown quantity at this point 
Solved Threads: 0
CE Student CE Student is offline Offline
Newbie Poster

The clever person who help me :)

 
0
  #1
May 15th, 2008
Hi!!!
How Are you
I bring a new program which I have solve it ; but there are 7 error without explain
pleaaaaaaaaaaaaaaaaase I hope that I have any body to help me and I will be happy
thhhhhanks alot


This is the question

Consider the following class definition:
class Section{ private :
int Sec; //section number.
int count; //number of the students in the section. long *IDs; //IDs of students in the section.
int maxSize // Variable to store the maximum size of ----------------IDs ( students) in the section
public:
Section (const Section & another); Section (int, int ,int);
void addlD(long);
int getCount ( ) ;
void print( ) const;
~Section ( ) ;}
1. Write the definition of class Section (above class) in a header file called “section.h”.
2. Complete the above class by writing the definitions of all member functions in another file (impClass.cpp) and include the header file “section.h”.
a. The Constructor function Section (int, int int) ; initializes the data member Sec , count and maxsize and allocates dynamically one dimensional array pointed by IDs.
b. The Constructor function Section (const Section & another); should copy the content object another to the current object. (copy constructor).
c. The Function addID should add an ID at the end of the array.
d. The function getCount should return the number of students in the section.
e. The function print should prints all students IDs in the section.
f. A Destructor function to destroy all dynamically allocated memory
3. write the main program that tests the above class in another file
(your-group-number.cpp) and include the-header file “section.h”.
Main should include the following:
1. Create an instance ( object) named Sec1 of type Section with sec=1, count=0 and maxSize =20.
2. Write a statement to add the id 111 to Sec1.
3. Write a statement to add the id 222 to Sec1.
4. Write a statement to print the details of Sec1.
5. Create an instance ( object) named Sec2 of type Section with the same IDs of Sec1 using the copy constructor.
6. Write a statement add the id 333 to Sec1.
7. Write a statement to print the details of Sec2.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 21
Reputation: CE Student is an unknown quantity at this point 
Solved Threads: 0
CE Student CE Student is offline Offline
Newbie Poster

Re: The clever person who help me :)

 
0
  #2
May 15th, 2008
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Section
  5. {
  6.  
  7. private :
  8. int Sec;
  9. int count;
  10. long *IDs;
  11. int maxSize;
  12.  
  13. public:
  14. Section (const Section & another);
  15. Section (int, int ,int);
  16. void addlD(long);
  17. int getCount ( ) ;
  18. void print( ) const;
  19. ~Section ( ) ;
  20. };
  21.  
  22.  
  23. #include<iostream>
  24. #include"section.h"
  25. using namespace std;
  26.  
  27. int main()
  28. {
  29. Section sec1(3,50,30);
  30. long IDs;
  31.  
  32. cout<<"enter the number of the students in the section";
  33. sec1.getCount();
  34.  
  35. cout<<"enter the Ids of the section";
  36. sec1.addlD(IDs);
  37. sec1.print();
  38. cout<<endl;
  39.  
  40.  
  41. Section sec2 (sec1);
  42. cout<<"after calling the function";
  43. cout<<"sec2";
  44. sec2.print();
  45.  
  46.  
  47. return 0;
  48.  
  49. }
  50.  
  51.  
  52.  
  53. #include<iostream>
  54. #include"section.h"
  55.  
  56. using namespace std;
  57.  
  58. Section::Section (int sect, int max ,int coun)
  59. {
  60.  
  61. Sec=sect;
  62. maxSize=max;
  63. count=coun;
  64.  
  65. IDs=new long [max];
  66.  
  67. }
  68.  
  69. Section::Section (const Section & another)
  70. {
  71. maxSize=another.maxSize;
  72. count=another.count;
  73.  
  74. IDs=new long [maxSize];
  75. for ( int i=0;i<count;i++)
  76. IDs[i]=another.IDs[i];
  77.  
  78. }
  79.  
  80. void Section::addlD(long)
  81. {
  82. for (int j=0; j<maxSize;j++)
  83. cin>>IDs [j];
  84. IDs++;
  85. }
  86.  
  87. int Section:: getCount ( )
  88. {
  89. return count;
  90.  
  91. }
  92.  
  93. void Section:: print( ) const
  94. {
  95. for (int j=0; j<maxSize;j++)
  96. cout<<IDs[j]<<"";
  97.  
  98.  
  99. }
  100.  
  101. Section::~Section ( )
  102. {
  103. delete [] IDs;
  104. }
Last edited by Narue; May 15th, 2008 at 5:36 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 21
Reputation: CE Student is an unknown quantity at this point 
Solved Threads: 0
CE Student CE Student is offline Offline
Newbie Poster

Re: The clever person who help me :)

 
0
  #3
May 15th, 2008
This is my try and i look to solve myyyyyy errrrooooor sooooooooooooon
good buy
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 351
Reputation: Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about 
Solved Threads: 62
Radical Edward's Avatar
Radical Edward Radical Edward is offline Offline
Posting Whiz

Re: The clever person who help me :)

 
0
  #4
May 15th, 2008
What errors are you getting? The code compiles for Edward with only a warning about IDs being used before initialization.
If at first you don't succeed, keep on sucking until you do succeed.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC