Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,565 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,902 people online right now. Registration is fast and FREE... Join Now!




Class and Object problem

 
Reply to this topicStart new topic

Class and Object problem, Multiple Errors in VS.

Rahlcepx516
18 May, 2008 - 11:54 AM
Post #1

New D.I.C Head
*

Joined: 19 Feb, 2008
Posts: 17

I just got into class and objects, and I am very confused in a whole as to why I am getting so many errors and why I can't return values. The program is suppose to be a console application that creates a class and a program that tests each member of that class, which I have all listed. Pretty much I am modeling and testing a resistor.

I still have more code to put in, but I can't get past these basics...
I have a descriptive UML made up if it would help to post that. Just ask.

CODE
#include <iostream>

using namespace std;

class ResistorClass
{
  private:
       double m_dResValue;
       double m_dTolerance;
       double m_dMinResistance;
       double m_dMaxResistance;
  public:
       string m_cResistorName;
       int DisplayResistor( );
       int EnterResistance ( );
       int AddSeries (ResistorClass Resistor1, ResistorClass Resistor1);
};

int main (void)
{
     //instatiate a resistor
     ResistorClass Resistor1;

     //give the resistor a %
     Resistor1.setm_dResValue(10.0);
     Resistor1.setm_dTolerance(0.10);
     Resistor1.setm_dMinResistance(9.0);
     Resistor1.setm_dMaxResistance(11.0);

     //output some facts about resistor one
     cout << "Resistor Class Test\n\n";
     cout << "Total resistance is "   << Resistor1.m_dResValue() << endl;
     cout << "Ohm resistance is "     << Resistor1.m_dTolerance() << endl;
     cout << "Minimum resistance is " << Resistor1.m_dMinResistance() << endl;
     cout << "Maximum resistance is " << Resistor1.m_dMaxResistance() << endl;

    
    return 0;
}

void ResistorClass::getResistor1
{
    Resistance = m_dResValue;
    Resistor ohm tolerance = m_dTolerance;
    Minimum resistance = m_dMinResistance;
    Maximum resistance = m_dMaxResistance;
}

User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Class And Object Problem
18 May, 2008 - 12:01 PM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,539



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
OK, well for one, you don't have a function in your class called
void ResistorClass::getResistor1


Secondly, you are calling functions in main that you haven't defined yet.

Thirdly, you don't initialise any of your private variables, even though you try to use them.

All in all, you have basically missed out a bunch of your code, but it shouldn't be too hard to fix smile.gif
User is offlineProfile CardPM
+Quote Post

Rahlcepx516
RE: Class And Object Problem
18 May, 2008 - 12:19 PM
Post #3

New D.I.C Head
*

Joined: 19 Feb, 2008
Posts: 17

QUOTE(gabehabe @ 18 May, 2008 - 01:01 PM) *

OK, well for one, you don't have a function in your class called
void ResistorClass::getResistor1


Secondly, you are calling functions in main that you haven't defined yet.

Thirdly, you don't initialise any of your private variables, even though you try to use them.

All in all, you have basically missed out a bunch of your code, but it shouldn't be too hard to fix smile.gif



lol, ok I'll do another run thru. Thanks
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 11:51PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month