New Posts  All Forums:Forum Nav:

quick c++ help

post #1 of 17
Thread Starter 
new to c++ and linked lists especially. I just started to learn linked lists in java but i have an assignment on them in c++, and could use a little help if anyone wouldn't mind!

this is the first part of main function,
Code:
    Locomotive::Wagon* wagonOne   = new Locomotive::Wagon( "one"   );
    Locomotive::Wagon* wagonTwo   = new Locomotive::Wagon( "two"   );
    Locomotive::Wagon* wagonThree = new Locomotive::Wagon( "three" );
    Locomotive::Wagon* wagonFour  = new Locomotive::Wagon( "four"  );
    Locomotive::Wagon* wagonFive  = new Locomotive::Wagon( "five"  );
    Locomotive::Wagon* wagonSix   = new Locomotive::Wagon( "six"   );
    Locomotive::Wagon* wagonSeven = new Locomotive::Wagon( "seven" );
    Locomotive::Wagon* wagonEight = new Locomotive::Wagon( "eight" );
    Locomotive::Wagon* wagonNine  = new Locomotive::Wagon( "nine"  );
    
    cout << "0 ---------- " << endl;

    Locomotive* santaFe  = new Locomotive( "Santa Fe" );
    Locomotive* topeka   = new Locomotive( "Topeka  " );
    Locomotive* atchison = new Locomotive( "Atchison" );

    cout << *santaFe  << endl; // prints "Santa Fe [ ]"
    cout << *topeka   << endl; // prints "Topeka   [ ]"
    cout << *atchison << endl; // prints "Atchison [ ]"

    cout << "1 ---------- " << endl;

    santaFe->addWagons( wagonOne   );
    santaFe->addWagons( wagonTwo   );
    santaFe->addWagons( wagonThree );
    santaFe->addWagons( wagonFour  );
    santaFe->addWagons( wagonFive  );
    santaFe->addWagons( wagonSix   );
    santaFe->addWagons( wagonSeven );
    santaFe->addWagons( wagonEight );
    santaFe->addWagons( wagonNine  );

so obviously i need to add all of those "wagons" to the santa fe train, is this how i would do that?
Code:
void Locomotive::addWagons(Wagon* aWagons) {
    // Adds a chain of wagons to the end of the train.
    if (Wagon* current = head) {
         head = aWagons;
         current = head -> next; }
    else
         current = aWagons;
         current = current -> next;
}

sorry if this is terrible, im a noob redface.gif
post #2 of 17
have u tried running it...I see a few things wrong...equality versus assignment...also check for null. You also didn't define Wagon *current or head in the code you provided. I'm assuming there is code you didn't show...
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 10 ASUS VS24AH-P 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 10 ASUS VS24AH-P 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
post #3 of 17
Is this the same from your other thread? smile.gif
I'll give it a look over in a bit! But the full code would be swell!
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #4 of 17
Thread Starter 
Code:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;


class Locomotive {
public:
    class Wagon {
    public:
        Wagon(string aName) {
        // Constructor initializing fields next (to NULL) and name (using argument)
                name = aName;
                name->getNext() = NULL;

        };
        string getName() { 
        // Returns the wagon’s number
                        return 0;                       
        };
        Wagon* getNext() {
        // Returns a pointer to the next wagon; or NULL if none follows
                        return 0;
                }
        void setNext(Wagon* aNext) {
        // References the given wagon as the next wagon
        }    
    private:
        string name;
        Wagon* next;
    };
  
    Locomotive(string aName) {
        // Constructor initializing fields head (to NULL) and name (using argument aName)
                name = aName;
                Wagon* name = head;
                head = NULL;
                
        };

    ~Locomotive() {
        while( head != NULL ) {
            Wagon* current = head;
            head = current->getNext();
            delete current;
        }
    }
    void     addWagons   ( Wagon* );
    Wagon*   detachWagons( int );
    Wagon*   getWagonAt  ( int );
    int      getSize     ();
    string   getName     ();

private:
    Wagon*  head;
    string  name;
};

void Locomotive::addWagons(Wagon* aWagons) {
    // Adds a chain of wagons to the end of the train.
}

// positions are 0-based, e.g., the first wagon is at position 0.
Locomotive::Wagon* Locomotive::detachWagons(int aPosition) {
    // Detaches and returns the chain of wagons that begins at a (0-based) index 
        // position. It returns NULL if the index is outside the boundaries of current wagons.
        return 0;
}

        // positions are 0-based, e.g., the first wagon is at position 0.
Locomotive::Wagon* Locomotive::getWagonAt(int aPosition) {
    // Returns a reference to the wagon at the (0-based) index position; or NULL if the 
        // index is outside the boundaries of current wagons. The list must not change.
        int desiredPos = aPosition;
        int currentPos = 0;
        Wagon* current = head;
        while(desiredPos != currentPos){
                currentPos ++;
                current = current->getNext();
        }
        return 0;
}

int Locomotive::getSize () {
        int size = 0;
    while( head != NULL ) {
                Wagon* current = head;
        head = current->getNext();
                size ++;}
        return size;
}

string Locomotive::getName() {
    // Returns the name of the locomotive
        return 0;
}

ostream& operator << (ostream& os, Locomotive& l) {
    // Overloaded  operator  function printing the information of a 
        // train to an output stream. The function prints in one line the 
        // name of the locomotive, space, [, space, the names of all 
        // wagons in this locomotive (separated by a space in between), 
        // space, ].
        return cout << " " << endl;
}

void assertEquals(Locomotive* train, Locomotive::Wagon* one, Locomotive::Wagon* two) {
    if (one != two) {
        string oneStr = "NULL";
        string twoStr = "NULL";
        if (one != NULL) {
            oneStr = one->getName();
        }
        if (two != NULL) {
            twoStr = two->getName();
        }
        cout << "ASSERT: [" << oneStr << "] is not expected [" << twoStr << "] @ " << train->getName() << endl;
        exit( 1 );
    }
}

/* Expected Output:
    0 ----------
    Santa Fe [ ]
    Topeka   [ ]
    Atchison [ ]
    1 ----------
    Santa Fe [ one two three four five six seven eight nine ]
    Topeka   [ ]
    Atchison [ ]
    2 ----------
    Santa Fe [ one two three ]
    Topeka  [ four five six seven eight nine ]
    Atchison [ ]
    3 ----------
    Santa Fe [ ]
    Topeka   [ four five six seven eight nine ]
    Atchison [ one two three ]
    4 ----------
    Santa Fe [ seven eight nine ]
    Topeka   [ four five six ]
    Atchison [ one two three ]

    Trains depart!
*/






the rest is main for testing purposes
Warning: Spoiler! (Click to show)
Code:
int main(array<System::String ^> ^args) {

        Locomotive::Wagon* wagonOne   = new Locomotive::Wagon( "one"   );
    Locomotive::Wagon* wagonTwo   = new Locomotive::Wagon( "two"   );
    Locomotive::Wagon* wagonThree = new Locomotive::Wagon( "three" );
    Locomotive::Wagon* wagonFour  = new Locomotive::Wagon( "four"  );
    Locomotive::Wagon* wagonFive  = new Locomotive::Wagon( "five"  );
    Locomotive::Wagon* wagonSix   = new Locomotive::Wagon( "six"   );
    Locomotive::Wagon* wagonSeven = new Locomotive::Wagon( "seven" );
    Locomotive::Wagon* wagonEight = new Locomotive::Wagon( "eight" );
    Locomotive::Wagon* wagonNine  = new Locomotive::Wagon( "nine"  );
    
    cout << "0 ---------- " << endl;

    Locomotive* santaFe  = new Locomotive( "Santa Fe" );
    Locomotive* topeka   = new Locomotive( "Topeka  " );
    Locomotive* atchison = new Locomotive( "Atchison" );

    cout << *santaFe  << endl; // prints "Santa Fe [ ]"
    cout << *topeka   << endl; // prints "Topeka   [ ]"
    cout << *atchison << endl; // prints "Atchison [ ]"

    cout << "1 ---------- " << endl;

    santaFe->addWagons( wagonOne   );
    santaFe->addWagons( wagonTwo   );
    santaFe->addWagons( wagonThree );
    santaFe->addWagons( wagonFour  );
    santaFe->addWagons( wagonFive  );
    santaFe->addWagons( wagonSix   );
    santaFe->addWagons( wagonSeven );
    santaFe->addWagons( wagonEight );
    santaFe->addWagons( wagonNine  );
  
    cout << *santaFe  << endl; // prints "Santa Fe [ one two three four five six seven eight nine ]"
    cout << *topeka   << endl; // prints "Topeka   [ ]"
    cout << *atchison << endl; // prints "Atchison [ ]"

    for (int i = -1; i <= santaFe->getSize(); i++) {
        Locomotive::Wagon* wagon = santaFe->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( santaFe, wagon, wagonOne   ); break;
            case 1 : assertEquals( santaFe, wagon, wagonTwo   ); break;
            case 2 : assertEquals( santaFe, wagon, wagonThree ); break;
            case 3 : assertEquals( santaFe, wagon, wagonFour  ); break;
            case 4 : assertEquals( santaFe, wagon, wagonFive  ); break;
            case 5 : assertEquals( santaFe, wagon, wagonSix   ); break;
            case 6 : assertEquals( santaFe, wagon, wagonSeven ); break;
            case 7 : assertEquals( santaFe, wagon, wagonEight ); break;
            case 8 : assertEquals( santaFe, wagon, wagonNine  ); break;
            default: assertEquals( santaFe, wagon, NULL );
        }
    }
    for (int i = -1; i <= topeka->getSize(); i++) {
        Locomotive::Wagon* wagon = topeka->getWagonAt( i );
        assertEquals( topeka, wagon, NULL  ); 
    }
    for (int i = -1; i <= atchison->getSize(); i++) {
        Locomotive::Wagon* wagon = atchison->getWagonAt( i );
        assertEquals( atchison, wagon, NULL  ); 
    }

    cout << "2 ---------- " << endl;

    Locomotive::Wagon* wagons;

    wagons = santaFe->detachWagons( 3 );
    topeka->addWagons( wagons );

    cout << *santaFe  << endl; // prints "Santa Fe [ one two three ]"
    cout << *topeka   << endl; // prints "Topeka   [ four five six seven eight nine ]"
    cout << *atchison << endl; // prints "Atchison [ ]"

    for (int i = -1; i <= santaFe->getSize(); i++) {
        Locomotive::Wagon* wagon = santaFe->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( santaFe, wagon, wagonOne   ); break;
            case 1 : assertEquals( santaFe, wagon, wagonTwo   ); break;
            case 2 : assertEquals( santaFe, wagon, wagonThree ); break;
            default: assertEquals( santaFe, wagon, NULL );
        }
    }
    for (int i = -1; i <= topeka->getSize(); i++) {
        Locomotive::Wagon* wagon = topeka->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( topeka, wagon, wagonFour  ); break;
            case 1 : assertEquals( topeka, wagon, wagonFive  ); break;
            case 2 : assertEquals( topeka, wagon, wagonSix   ); break;
            case 3 : assertEquals( topeka, wagon, wagonSeven ); break;
            case 4 : assertEquals( topeka, wagon, wagonEight ); break;
            case 5 : assertEquals( topeka, wagon, wagonNine  ); break;
            default: assertEquals( topeka, wagon, NULL );
        }
    }
    for (int i = -1; i <= atchison->getSize(); i++) {
        Locomotive::Wagon* wagon = atchison->getWagonAt( i );
        assertEquals( atchison, wagon, NULL  ); 
    }

    cout << "3 ---------- " << endl;

    wagons = santaFe ->detachWagons( 0 );
    atchison->addWagons( wagons );

    cout << *santaFe  << endl; // prints "Santa Fe [ ]"
    cout << *topeka   << endl; // prints "Topeka   [ four five six seven eight nine ]"
    cout << *atchison << endl; // prints "Atchison [ one two three ]"

    for (int i = -1; i <= santaFe->getSize(); i++) {
        Locomotive::Wagon* wagon = santaFe->getWagonAt( i );
        assertEquals( santaFe, wagon, NULL  ); 
    }
    for (int i = -1; i <= topeka->getSize(); i++) {
        Locomotive::Wagon* wagon = topeka->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( topeka, wagon, wagonFour  ); break;
            case 1 : assertEquals( topeka, wagon, wagonFive  ); break;
            case 2 : assertEquals( topeka, wagon, wagonSix   ); break;
            case 3 : assertEquals( topeka, wagon, wagonSeven ); break;
            case 4 : assertEquals( topeka, wagon, wagonEight ); break;
            case 5 : assertEquals( topeka, wagon, wagonNine  ); break;
            default: assertEquals( topeka, wagon, NULL );
        }
    }
    for (int i = -1; i <= atchison->getSize(); i++) {
        Locomotive::Wagon* wagon = atchison->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( atchison, wagon, wagonOne   ); break;
            case 1 : assertEquals( atchison, wagon, wagonTwo   ); break;
            case 2 : assertEquals( atchison, wagon, wagonThree ); break;
            default: assertEquals( atchison, wagon, NULL );
        }
    }
    
    cout << "4 ---------- " << endl;

    wagons = topeka->detachWagons( 3 );
    santaFe->addWagons( wagons );

    cout << *santaFe  << endl; // prints "Santa Fe [ seven eight nine ]"
    cout << *topeka   << endl; // prints "Topeka   [ four five six ]"
    cout << *atchison << endl; // prints "Atchison [ one two three ]"

    for (int i = -1; i <= santaFe->getSize(); i++) {
        Locomotive::Wagon* wagon = santaFe->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( santaFe, wagon, wagonSeven ); break;
            case 1 : assertEquals( santaFe, wagon, wagonEight ); break;
            case 2 : assertEquals( santaFe, wagon, wagonNine  ); break;
            default: assertEquals( santaFe, wagon, NULL );
        }
    }
    for (int i = -1; i <= topeka->getSize(); i++) {
        Locomotive::Wagon* wagon = topeka->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( topeka, wagon, wagonFour  ); break;
            case 1 : assertEquals( topeka, wagon, wagonFive  ); break;
            case 2 : assertEquals( topeka, wagon, wagonSix   ); break;
            default: assertEquals( topeka, wagon, NULL );
        }
    }
    for (int i = -1; i <= atchison->getSize(); i++) {
        Locomotive::Wagon* wagon = atchison->getWagonAt( i );
        switch (i) {
            case 0 : assertEquals( atchison, wagon, wagonOne   ); break;
            case 1 : assertEquals( atchison, wagon, wagonTwo   ); break;
            case 2 : assertEquals( atchison, wagon, wagonThree ); break;
            default: assertEquals( atchison, wagon, NULL );
        }
    }
    
    // a couple of negative cases
    wagons = santaFe->detachWagons( -1 );
    assertEquals( santaFe, wagons, NULL );
    
    wagons = topeka->detachWagons( 3 );
    assertEquals( topeka, wagons, NULL );

    delete santaFe;
    delete topeka;
    delete atchison;

    cout << "\nTrains depart!" << endl;

    return 0;
}






thats all i got so far redface.gif
for the getWagonAt() im not really sure how i would return the contents of it!


also for the getNext and get name idk how to return what the linked list is at that point.
I know like in class we used item like head.item to get whatever is at head. but in this sense im lost!
post #5 of 17
I don't have time to pound out a long winded explanation or a bunch of code today unfortunately redface.gif
But, I will refer you to here: http://www.functionx.com/cpp/articles/linkedlist.htm

biggrin.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #6 of 17
Thread Starter 
I know i wasn't trying to pour it on you tongue.gif thanks for the link!

could ya atleast help with a tiny part biggrin.gif i know its easy but like i said the way im doing it here is diff from what we did in my other class,

how would i return get name or get wagon at since they are pretty similar
post #7 of 17
It's very early in the morning for me here so forgive me if I understood wrong, but it looks like getName could be:
Code:
string Locomotive::getName() {
    // Returns the name of the locomotive
        return this->name;
}

Same thing for the getName on your Wagon class smile.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #8 of 17
Thread Starter 
ahh that simple hahah! makes me feel so stupid smile.gif

btw whats your job! im interested!
post #9 of 17
Quote:
Originally Posted by protzman View Post

ahh that simple hahah! makes me feel so stupid smile.gif
btw whats your job! im interested!

Never feel stupid wink.gif
My job involves little programming nowadays... Its just as a hobby more now, but I do network management, PC repairs and all that nice boring stuff (or not..) smile.gif
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #10 of 17
Thread Starter 
network management is cool i think! i mean i dont know exactly how or what you do but the concept imo is sweet! something i want to learn someday!
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming