modifyByValue vs modifyByReference

Pages: 12
They don't have to. They can be created inside any scope - that includes outside functions, inside functions, inside classes, inside a class' member function, inside a for loop, etc.
L B I NEED TO CREATE A NODE CLASS THAT STORES AN INTEGER.

1
2
3
4
class Node
{
    int x;
};
Unless you get more specific I can't really help.
plz stop using caps
Thanks LB,
but the first thing i have to do is to create a List class with the following two interface:
List::addItem //add an item to the list
List::getTheLargestValue //find the largest value stored in the list

the largest value among the integers i want to store in the list
the node i want to create is to store those integers
What do you have so far?
class Node {

Node*nextNode;
int itemNumber;

Node* getNextNode () {return nextNode;}
cout<<"The largest value is: " << Largest Node >>printValue();

};


int main (){
List aList;

Next*largestNode = aList*getLargestNode ();

}

this is what i get so far
i'm not sure i'm on the right track

getNextNode() needs to be public.
that cout statement doesn't belong in the direct scope of a class, not does the function T &printValue(void); exist.
List class does not exist.
List getLargestNode(void) does not exist
Class Next does not exist
Next *operator*(const List &, const List &) does not exist
i'm really confused now
can you write a sample?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class SimpList
{
    struct Node
    {
        Node *next;
        double value;
        Node() : next(0) {}
    } *head;
public:
    SimpList() : head(0) {}
    void Add(double v)
    {
        if(!head)
        {
            head = new Node;
            head->value = v;
            return;
        }
        Node *p = head;
        while(p->next) p = p->next;
        p->next = new Node;
        p->next->value = v;
    }
    ~SimpList()
    {
        if(!head) return;
        Node *p = head;
        while(p->next)
        {
            Node *t = p;
            p = p->next;
            delete t;
        }
        delete p;
    }
};
Here is a sample. However, it is not necessarily what your assignment wants.
Using inheritance, i have a base class and two derived classes. One derived class is to insert an integer, the other derived class is to insert a character. I need help writing this code.

What do you mean by insert?
in this context insert means add an integer, add a character to a list
OK, what list will the integer and character be added to?
the class List as the base class
That assignment doesn't make sense.
Here is the model of what I'm talking about:

class List {
public:
.............
.............

};

class intNode: public List
public:
{
........
........
};

class charNode: public List
public:
{
.............
.............

};
Topic archived. No new replies allowed.
Pages: 12