Thread: Undeclared identifier major problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    11

    Undeclared identifier major problem

    First of all id like to say Hi! im new to this forum and stumbled upon it via google really realllly need some help with this assignment im doing at University, i'm missing something pretty fundamental i think.

    I have two classes, I first run the userdisplay and get values...these values are then calculated in the other class...but i cant get the classes to see the private variables such as Resistance. I have created 2 header files and 2 Cpp files

    Code:
    //Main Function - Responsible for Running program
    //All C++ Projects need a main function
    
    #include <iostream>
    using namespace std;
    
    #include "RLCSeriesCircuit.h"
    #include "Simulation.h"
    
    int main (void)
    {
    	char Restart; //declare variable restart as type char
    
    	do 
    	{
    	system("CLS"); //Clears the Screen (Stage 2 on Activity)
    	Simulation mySimulation; //object
    	mySimulation.Userdisplay(); //executes first function
    	
    
    	cout << "\nDo you want to Restart the Program? (y/n): " ; //loop to restart whole program
    	cin >> Restart;  //stores into char variable restart
    
    	}
    while (Restart== 'y'); //Restarts if user enters in character y
    
    cout << "\nEnd of program\n\n"; //outputs simple statement stating program has ended
    system ("Pause"); //Pauses Program and displays "press any key to continue"
    
    return 0;
    }
    Code:
    //Header File for CLass Simulation
    //Created by Daniel Jackson
    
    #include <iostream>
    using namespace std;
    
    
    class Simulation
    {
    public:
    	void Userdisplay(void);
    	
    
    private:
    	double Resistance;
    	double Inductance;
    	double Capacitance;
    	double VS;
    	double MinFreq;
    	double MaxFreq;
    	double Freqsteps;
    };
    Code:
    //Simulation C++ File
    //Created by Daniel Jackson
    
    #include <iostream>
    #include <iomanip>
    using namespace std;
    #include <cmath>
    using std::pow;
    using std::log;
    using std::setprecision;
    #include <string>
    using std::string;
    using std::getline;
    
    #include "Simulation.h" //include Simulation Class Definition
    #include "RLCSeriesCircuit.h" //include RLCSeriesCircuit class defniition
    
    
    
    
    void Simulation::Userdisplay () //1st Function (User inputs)
    {
    	
        cout << "**********************************************************\n"; //user display (start)
    	cout << "* 205SE Assignment                                       *\n";
    	cout << "* Created by Daniel Jackson (SID: 1641552)               *\n";
    	cout << "* This program simulates the behaviour of an             *\n";
    	cout << "* RLC circuit based on user inputs                       *\n";
    	cout << "**********************************************************\n";
    
    	cout << "\nRLC Series circuit Simulation"; //Program Title (Stage 3 of Activity)
    	cout << "\nEnter the values for the circuit components:\n";
    
    
    	cout << "\nPlease enter Resistance value[Ohms] -> "; //Prompt for R (Stage 4 of Activity)
    	cin >> Resistance; //Read in R (Stage 4 of Activity)
    
        cout << "\nPlease enter Inductance value[H] -> "; //Pompt for L (Stage 4 of Activity)
    	cin >> Inductance; //Read in L (Stage 4 of Activity)
     
    	cout << "\nPlease enter Capacitance value[F] -> "; //Prompt for C (Stage 4 of Activity)
    	cin >> Capacitance; //Read in C (Stage 4 of Activity)
    
    	cout << "\nEnter the operating conditions:\n";
    	
    	cout << "Enter supply Voltage [V] -> "; //prompt for supply voltage
    	cin >> VS; //Read in supply Voltage
    
    	cout << "Enter Min Supply frequency [Hz] -> "; //prompt for minimum supply frequency
    	cin >> MinFreq; //Read in Minimum Frequency
    
    	cout << "Enter Max supply frequency [Hz] -> "; //prompt for maximum frequency
    	cin >> MaxFreq; //Read in Maximum Frequency
    
    	cout << "Enter No. of frequency steps required -> "; //prompt for number of freq steps
    	cin >> Freqsteps;
    
    	RLC_Series_Cct Circuit;
        Circuit.getResistance();
    	Circuit.getCapacitance();
    	Circuit.getInductance();
    	Circuit.Incrementloop();
    
    }
    Code:
    //Header file for RLC Series CIrcuit
    //Created by Daniel Jackson
    #include <iostream>
    using namespace std;
    
    
    class RLC_Series_Cct
    {
    public:
    	void Incrementloop();
    	double getResistance();
    	double getInductance();
    	double getCapacitance();
    private:
    	double actualFreq;
    	double Z;
    	double I;
    	double VR;
    	double NF;
    	double XL;
    	double XC;
    	double VOVR;
    	int iteration;
    	int Maxstep;
    		
    };
    Code:
    //RLC Series Circuit C++ File
    //Created by Daniel Jackson
    
    #include <iostream>
    #include <iomanip>
    using namespace std;
    #include <cmath>
    using std::pow;
    using std::log;
    using std::setprecision;
    #include <string>
    using std::string;
    using std::getline;
    
    #include "Simulation.h"
    #include "RLCSeriesCircuit.h"
    
    const double pi = 3.1415926535; //Global constant
    
    double RLC_Series_Cct::getResistance()
    {
    	return Resistance;
    }
    
    double RLC_Series_Cct::getCapacitance()
    {
    	return Capacitance;
    }
    
    double RLC_Series_Cct::getInductance()
    {
    	return Inductance;
    }
    
    void RLC_Series_Cct::Incrementloop() //2nd function (calculation with for loop)
    	{
    		
    		cout << right; // one time exectution
    		cout.fill ('*');
    		
    		NF = (((2*pi*sqrt(Inductance*Capacitance()))/1)); //Calculate Natural Frequency 	
    		Maxstep = ((log10(MaxFreq) - log10(MinFreq))/(0.1)); //incerement calculation
    		cout << "Voltage ratio plot at each frequency step:\n\n"; //introduces chart
    			
    				for (iteration= 1; iteration<= Maxstep; iteration++) //for loop begins 
    				{
    				actualFreq = (MinFreq * pow(10.0, (0.1 * iteration))); // plot Voltage ratio
    				XL = (2 * pi * actualFreq * Inductance); //Calculation 
    				XC = (1/ (2 * pi * actualFreq * Capacitance)); //Calculation 
    				Z = (sqrt(Resistance * Resistance + (XL - XC) * (XL - XC))); //Calculation 
    				I = (VS / Z); //Calculation 
    				VR = (I * Resistance); //Calculation 
    				VOVR = (VR / VS); //Calculation 
    				 	
    				cout << setw(VOVR * 100) << actualFreq << setprecision (2) << endl;
    				}
    				
    			
    			cout << "\nNatural frequency of circuit = " << NF << setprecision( 2 ); //outputs Natural Frequency to user
    
    }
    1>c:\data\jacks1d\my documents\visual studio 2008\projects\rlc project 2\rlc project 2\rlcseriescircuit.cpp(42) : error C2065: 'MaxFreq' : undeclared
    identifier
    1>c:\data\jacks1d\my documents\visual studio 2008\projects\rlc project 2\rlc project 2\rlcseriescircuit.cpp(32) : error C2065: 'Inductance' : undeclared identifier
    1>c:\data\jacks1d\my documents\visual studio 2008\projects\rlc project 2\rlc project 2\rlcseriescircuit.cpp(27) : error C2065: 'Capacitance' : undeclared identifier


    Examples of the errors im getting are above...seems no matter what i try i cannot call them variables....
    Last edited by Danieljax88; 03-27-2010 at 12:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM