creating methods/functions in a seperate file
-
Hi all, i am very very new to c++ hope u guys can pardon me. I have a file called "newclass.h" which declares a few methods.
//newclass.h, the specification file for the class NewClass
#ifndef _NEWCLASS_H
#define _NEWCLASS_H
#include <string>using namespace std;
class NewClass {
public:string symbol; //variable to store the symbol (e.g.: Nasdaq)
double lastTrade; //variable to store the last traded value
double changeValue(); //variable to store the change in value
double changePercentage(); //variable to store the change in percentage//function to get the respective values
//the word const at the end of the member functions specify that these functions cannot modify the member variables of a variable
void getDow(string symbol, double, double, double) const;
void getNasdaq(string symbol, double, double, double) const;
void getSP_500(string symbol, double, double, double) const;
void getFTSE_100(string symbol, double, double, double) const;
void getDAX(string symbol, double, double, double) const;
void getNikkei_225(string symbol, double, double, double) const;
void getHang_Seng(string symbol, double, double, double) const;
void getStraits_Times_Index(string symbol, double, double, double) const;
};
#endifand the other file i have is "newclass.cpp"
//newclass.cpp, the implementation file
#include #include "newclass.h"using namespace std;
how do i continue writing the main function of the method in newclass.cpp thanks
-
Hi all, i am very very new to c++ hope u guys can pardon me. I have a file called "newclass.h" which declares a few methods.
//newclass.h, the specification file for the class NewClass
#ifndef _NEWCLASS_H
#define _NEWCLASS_H
#include <string>using namespace std;
class NewClass {
public:string symbol; //variable to store the symbol (e.g.: Nasdaq)
double lastTrade; //variable to store the last traded value
double changeValue(); //variable to store the change in value
double changePercentage(); //variable to store the change in percentage//function to get the respective values
//the word const at the end of the member functions specify that these functions cannot modify the member variables of a variable
void getDow(string symbol, double, double, double) const;
void getNasdaq(string symbol, double, double, double) const;
void getSP_500(string symbol, double, double, double) const;
void getFTSE_100(string symbol, double, double, double) const;
void getDAX(string symbol, double, double, double) const;
void getNikkei_225(string symbol, double, double, double) const;
void getHang_Seng(string symbol, double, double, double) const;
void getStraits_Times_Index(string symbol, double, double, double) const;
};
#endifand the other file i have is "newclass.cpp"
//newclass.cpp, the implementation file
#include #include "newclass.h"using namespace std;
how do i continue writing the main function of the method in newclass.cpp thanks
You seem to be really confused about a lot of basic concepts in C++. I strongly suggest you start by reading a book (from the begining) about the C++ language first.
Cédric Moonen Software developer
Charting control [v3.0] OpenGL game tutorial in C++ -
Hi all, i am very very new to c++ hope u guys can pardon me. I have a file called "newclass.h" which declares a few methods.
//newclass.h, the specification file for the class NewClass
#ifndef _NEWCLASS_H
#define _NEWCLASS_H
#include <string>using namespace std;
class NewClass {
public:string symbol; //variable to store the symbol (e.g.: Nasdaq)
double lastTrade; //variable to store the last traded value
double changeValue(); //variable to store the change in value
double changePercentage(); //variable to store the change in percentage//function to get the respective values
//the word const at the end of the member functions specify that these functions cannot modify the member variables of a variable
void getDow(string symbol, double, double, double) const;
void getNasdaq(string symbol, double, double, double) const;
void getSP_500(string symbol, double, double, double) const;
void getFTSE_100(string symbol, double, double, double) const;
void getDAX(string symbol, double, double, double) const;
void getNikkei_225(string symbol, double, double, double) const;
void getHang_Seng(string symbol, double, double, double) const;
void getStraits_Times_Index(string symbol, double, double, double) const;
};
#endifand the other file i have is "newclass.cpp"
//newclass.cpp, the implementation file
#include #include "newclass.h"using namespace std;
how do i continue writing the main function of the method in newclass.cpp thanks
something like :
void NewClass::getDow(string symbol, double value1, double value2, double value3) const
{
// ... do the code to get the Dow values for the supplied symbol.
}use the same pattern for the other methods. Since I do not know what the 3 double variables are, I simply called them value1, value2, value3; I assume that they really mean something; and if they are "returned" values (i.e. variables that you will assign something to them), you better make them either references (prefered) or pointers. good luck.
This signature was proudly tested on animals.
-
Hi all, i am very very new to c++ hope u guys can pardon me. I have a file called "newclass.h" which declares a few methods.
//newclass.h, the specification file for the class NewClass
#ifndef _NEWCLASS_H
#define _NEWCLASS_H
#include <string>using namespace std;
class NewClass {
public:string symbol; //variable to store the symbol (e.g.: Nasdaq)
double lastTrade; //variable to store the last traded value
double changeValue(); //variable to store the change in value
double changePercentage(); //variable to store the change in percentage//function to get the respective values
//the word const at the end of the member functions specify that these functions cannot modify the member variables of a variable
void getDow(string symbol, double, double, double) const;
void getNasdaq(string symbol, double, double, double) const;
void getSP_500(string symbol, double, double, double) const;
void getFTSE_100(string symbol, double, double, double) const;
void getDAX(string symbol, double, double, double) const;
void getNikkei_225(string symbol, double, double, double) const;
void getHang_Seng(string symbol, double, double, double) const;
void getStraits_Times_Index(string symbol, double, double, double) const;
};
#endifand the other file i have is "newclass.cpp"
//newclass.cpp, the implementation file
#include #include "newclass.h"using namespace std;
how do i continue writing the main function of the method in newclass.cpp thanks
A friendly piece of advice: never use double (or float) for currency values[^]