class CObjects {
int m_CurrentTime;
int m_Steps;
AStarList* OPEN;
AStarList* CLOSED;
std::vector<AStarNode *>solution;
[code]....
CCB is derived from CrowdEntity and in turn is derived from CObjects Inside CObjects, I declared AStarList *OPEN; Why would howmany become garbage (cdcdcdcd) when I reference it in GetBestNode()
I've got this sorting program that uses variables from another class but I'm not sure why its not recognizing it. I'm getting an error length and list not declared in this scope.
#include <iostream> #include "arrayListType.h" using namespace std; template<class elemType> class orderedArrayListType: public arrayListType<elemType> {
C++ Create a Triangle class that has the following member variables: side1 - a double side2 - a double side 3 - a double perimeter area
The class should have the following member functions:
- default constructor that sets the value of all 3 sides of a triangle to 0.0
- a constructor with arguments that accepts values for the three sides of a triangle (member variables) as arguments
- setDimensions - a function that allows the value of the three sides to be entered by the user through the keyboard
- testSides - a function that determines if the 3 values entered can actually be the sides of a triangle. If they do not create a triangle, print the values entered and an appropriate message --The sum of any two side lengths of a triangle must always be greater than the length of the third side: so side 1 + side 2 > side 3 and side 1 + side 3 > side 2 and side 2 + side 3 > side 1 ( all three must be true for the 3 values to make a triangle)
- getSide1 - a function that returns the value of side 1, getSide2 - a function that returns the value of side 2, getSide3 - a function that returns the value of side 3
- getArea - a function that returns the area of a triangle: The formula for the area of a triangle (when the height is not known) is: A = sqrt (p(p-side1)(p-side2)(p-side3)) where p = (side1+side2+side3)/2
- getPerimeter - a function that returns the perimeter of a triangle: Perimeter = side1 + side2+ Side 3
- A displayTriangleInfo function that displays side1, side2, side3, area, and perimeter for a triangle object.
After testing your code for a single object, create an array of 5 triangles. Use a for loop and the setDimensions function to allow the user to set the values for the 3 sides of a triangle, test the vales entered to determine if the 3 create a triangle. If they do create a triangle than use the getArea and getPerimeter functions to calculate the Area and Perimeter for the triangle and use the displayTriangleInfo function to display all of the data for that triangle. If the three values do not create a triangle then print the 3 numbers entered and an appropriate message. In either case the loop should then move on and get the data for the next triangle from the user.
Suppose I have two classes, MyClassX and MyClassY, each with two member variables, as defined below. I create an object instance of each class, and then create a pointer to each member variable for each object:
Code: class MyClassX { public: int a; double b; MyClassX(int _a, double _b)
[code]....
After converting the hexadecimal to decimal, it appears that with MyClassX, pxb is 8 bytes from pxa, whereas for MyClassY, pya is only 4 bytes from pyb. This makes sense for MyClassY, because the first member variable to be stored is an int, and so will occupy 4 bytes. However, why should this be any different for MyClassX, which also has an int as the first member variable, so shouldn't this also occupy 4bytes?
The reason I have come across this problem is that I am looking into streaming objects to memory and then loading them again. (I know boost can do this, but I am trying it out myself from scratch.) Therefore, this is causing an issue, because I cannot just assume that the size of memory occupied by an object is just the sum of the sizes of its member variables. MyClassX is 8 bytes larger than MyClassY, even though the intuition is that it should only occupy 4 bytes more due to a double being replaced by an int.
I have two classes, a Package class and a Person class. The Package class has two Person objects has member variables, a Sender and a Receiver. While overloading the << operator for the Package class so that it will make an output label from everything in the Package class. Here is my code...
class Package{ public: Person Sender; Person Reciever; int weight; double cost; friend ostream &operator<<(ostream &out, Package &pack);
[Code] .....
So my problem is on that last output line, I am unable to call Sender.getName()... etc. Is there a proper syntax so that I can access the members of the Person class while overloading the << operator for the Package class?
Code: vector<int>& function(int a , int b){ vector<int> s(3000000); vector<int> xxx(4); return xxx }
Not to board people with details but if i am returning the the reference to a vector xxx what happens to vector s. is it destroyed ?? it should be, but i don't see it on my memory map (memory is not released) . can this be or should i go and search for error on some other place.....
#include <iostream> #include <vector> #include <cmath> #include "ANN.h" using namespace std; const int NUM_HIDDEN_NEURONS = 3;
[Code] ....
So I am getting 2 errors. Here is both of them.
ANN.cpp: In member function "void ANN::JustDoIt()": ANN.cpp:36: error: "class std::vector<HiddenNeuron, std::allocator<HiddenNeuron> >" has no member named "SetWeights" ANN.cpp: In member function "void ANN::SetData(double, double)": ANN.cpp:85: error: "SetNeuronData" was not declared in this scope
Are there any situations to explicitly use the scope resolution operator with global scope? I can imagine a situation like:
#include <cmath> class IntWrapper{ public: IntWrapper& pow(char); IntWrapper(char); private: int m_int;
[Code] ....
But then I would think that the writer should have used a different name, and that using the scope resolution operator in the constructor body is still pointless...
I'm struggling with the whole stack/heap thing. I totally see the need to create objects on the free store to outlive functions, however, I don't see the purpose of "new" when working with classes.
Code: class Person{ public: Person(std::string strName, int number); ~Person(void);
Resource r;
[Code] .....
Now, what is the difference? Why would I need to create a Resource on the free store? Both variables named r live until the destructor runs, right?
I have created a windows form project in visual studio so that I can use a windows form to interact with the game class that I'm creating, but I'm running into some problems.
For one thing, I would like to be able to call Image::FromFile() one time only during initialization, and store the result in a member variable (called mBGImage). From what I can tell, the variable needs to be of type String^ (this caret symbol is new to me, but I understand it is the "managed code" version of the standard pointer, which would look like String*).
When I try to compile the following code (located in my header file) I get the error :
"error C3265: cannot declare a managed 'mBGImage' in an unmanaged 'BSG::BSGame'".
How can I store the result of Image::FromFile() permanently in my class?
When I try to declare a global variable of type "Image^", I get "error C3145: global or static variable may not have managed type System:rawing::Image ^"
#include "stdafx.h" using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms;
I am writing a program which is using SDL library. I have two different classes which one of them is Timer Class and the other is EventHandling Class.
I need to use some member functions and variables of Timer in some Eventhandling Class member functions, Although I want to define an object of Timer in int main {} and relate it to its member function that has been used in Eventhandling member function in order that it becomes easier to handle it, I mean that I want to have for example two objects of timer and two objects of Eventhandling class for two different users.
I do not know how to relate an object of a class from int main{} to its member function which is being used in another class member function.
So I have an ImageManager class, Board class, and Box class. In Board.h I can declare ImageManager imgr; and in Board's constructor I can use imgr and its functions and such. However, in Box.h when I try and declare ImageManager imgr; I get the error "cannot access member declared in class ImageManager". Both declarations are under private, and exactly the same, but one doesn't work. Also, is there a way to only have one instance of ImageManager?
I am having compiling issues and am looking for an explanation as to what is causing the error and how to fix it. The declaration of 'g4vuplInstanceID' seems to be global in scope in my option, however I may be wrong.
Compiler Error: error: 'class myPhysListGeneral' has no member named 'g4vupInstanceID'
I am working on a homework assignment and have most of the program working, but when I try to compile it keeps telling me to initialize the coin variables in each class. However, they are supposed to be added then removed so I don't want to set them back to zero.
Rewrite the Purse program given in Page 35 with functions to perform insert and remove operations. The function insert (int p, int n, int d, int q) will initialize pennies, nickels, dimes and quarters. The function dollars() will return the dollars. The function remove (int p, int n, int d, int q) will subtract pennies, nickels, dimes and quarters. The function display() returns a new String to print the content of the purse with remaining pennies, nickels, dimes and quarters.
Code: usingnamespace std; int insert_money (int *p, int *n, int *d, int *q); int remove_money (int *p, int *n, int *d, int *q); int dollars(); int main()
I've been attempting to create a game with curses and I keep running into the problem of scope. I want to change or use variables of a different class in a different header file. But I don't know if I should use pointers, references or neither. Should I be programming in a manner that doesn't make it necessary to use variables outside of their class?
I mount a function (parameter - numeric vector; returns a string). However, this same function is used in several classes. To avoid that I keep duplicating the same code within these classes there is a way to do that as the code below?
std::string func( const vector<int> vec ) { //processamento return result; } class A {
If you are doing some big program, usually, how do you organize the files? Put the class and its member in head file, but where to declare non member functions and where to define them? I don't want to put them all in one cpp file. If not, how to make them visible to the main cpp file?
we have to make a Invoice class which has a function called computeInvoiceAmount() which multiplies the price and the quantitiy which are private member of the class.
I'm trying to change the values of some instance variables in my Controller Class so that when the user inserts values into main class it changes for Controller.
class Controller { public: Controller(); ~Controller(); double PCFreq; __int64 CounterStart;
[Code] ....
The user should be able to choose which foo the want to use. So I create an object of controller in main like this
Controller* con = new Controller()
Now my issues is, when I take user input (an integer) and try to do this
con->choice1 = choice1;
only the object of con's choice1 is = to user input.
However back at the class for Controller, choice1 hasn't received a value.
I can't initialize through Controllers constructor because I get the user input through a switch statement and the range of con would only be as far as the case.