Search:
Type: Posts; User: heat89
Search:
Search took 0.03 seconds.
-
June 17th, 2009, 12:00 PM
#include <iostream>
#include <fstream> //allow writing to file instead of cout
#include <cstring>
using namespace std;
#include "date.h"
#include "person.h"
#include "student.h"
#include...
-
June 16th, 2009, 10:14 AM
Thanks for the help.
No the copy constructor was not complete at that time, I have since attempted to complete it:
class Student : public Person {
public:
Student(const char *...
-
June 14th, 2009, 01:07 PM
Thanks for the help.
I'd like to understand a little more though instead of just pasting in what you're telling me to. I was under the impression that the copy constructor is perfectly defined...
-
June 14th, 2009, 12:42 PM
I see, any tips on how to make it defined? I tried to stick an int in front of it (semi-knowing it wouldn't work) and it gave me lots of errors so I'm thinking that isn't the way to get it done.
-
June 14th, 2009, 11:57 AM
See I tried that before posting here for some help by doing
class Student : public Person {
public:
Student(const char * their_name, const char * email, const Date & d, const char * sch,...
-
June 13th, 2009, 06:33 PM
So I have a Person class which is the base class for another class called Student (inherits from Person).
I'm getting a couple errors but I'm not sure where they are coming from...
Person...
-
Thanks for the help.
Does the new object have to be the same type as the existing object?
-
Also when and why should they be used?
I know you are given them both for free if you don't assign them, but why do we need to assign them in the first place?
-
Ok so I see why A() is being printed first, I'm guessing because there's no initializer list it goes to the that reads A a in the B class which in turn goes to A() method which prints out "A()".
...
-
Here is some code that puts to use copy constructors and assignment operators:
#include <iostream>
using namespace std;
class A {
int n;
public:
-
Oh I see what you mean, ok thanks I'm going to try and approach this from another angle, thanks for your help!
-
Do you mind clarifying what you mean by the delete element[0] statement deletes the same element? Do you mean it deletes the same element the second time its called? Or are you saying even the first...
-
Thanks, I will make the appropriate changes as you suggested, it should be numberOfElements in the for-loop.
Here is my main:
#include <iostream>
#include "date.h"
#include "loan.h" ...
-
void add(Loan & aLoan)
{
if (numberOfElements == capacity)
{
std::cout << "Container is growing.\n";
Loan ** temp = elements;
elements = new Loan*[capacity*2];
for(int i=0;...
-
So that's why my program is crashing then right?
What is the appropriate method of deleting the first element from the elements array then?
-
A thought just came to me, I'm creating the array like this:
elements = new Loan*[initial_size];
is delete elements[0] even the right way of deleting the first element? I seem to remember my...
-
Well it still crashes at the same spot, but I will work with what I have, thanks again.
-
That would be elements[2] = elements[3] actually.
-
Yes I think so.
If we have 3 elements, then my for-loop was telling the program to do elements[3] = elements[4]. Can't happen though if there's only 3 elements to begin with. Does that sound about...
-
Yeah I understand that, of course I don't expect anyone to have a specific answer to this right off the bat, but I do appreciate all the advice, generic or not it does help me understand different...
-
Thanks for the reply Paul,
Even as a beginner programmer (especially in C++) there are things I know I'd do differently/more efficiently if it were up to me, but since these are part of assignment...
-
Well here's the part of the main function which I'm calling the removeFirst() method from:
for(int i = 0; i<numberOfCarLoans ; i++)
{
Loan & aLoan = carLoans.removeFirst(); //important...
-
for (int i = 0; i < numberOfElements; i++)
{
elements[i] = elements[i + 1];
}
Does that look better?
It still seems to crash after deleting the first element.
-
What are you talking about?
-
Sorry I hadn't checked his reply here when I posted that.
|
Click Here to Expand Forum to Full Width
|