1,177 Posted Topics

Member Avatar for Swemp

Note that c++ arrays are 0 based. That is, array[0] is the first element, not array[1]. Dave

Member Avatar for Swemp
0
5K
Member Avatar for NewtoC++

The constructor of your class simply needs to be called after the values have been input, and passed those input values. [code] class Person { string Name; int Age; Person(const string name, const int age) : Name(name), Age(age) {} }; [/code] That syntax is called an "initialization list". It means …

Member Avatar for NewtoC++
0
18K
Member Avatar for serkan sendur
Member Avatar for Yuichi
Member Avatar for almazyoon

that looks like the log function, "L"n (LN) not "I"n (IN). That should be a good place to start. You seem not to have attempted to write that part of the code at all. Give it a shot and let us know how it goes. Dave

Member Avatar for VernonDozier
0
126
Member Avatar for Manutebecker

I dont' really understand either, but maybe you just want to put a vector in the derived class instead of in the base class?

Member Avatar for Manutebecker
0
105
Member Avatar for Shinedevil

You should try to make the question as limited as possible. "I would like to write a number to a file, and then later retrieve that number from a file." is much clearer than something about a game and a quest, etc. Try to get a sample application working (using …

Member Avatar for daviddoria
0
140
Member Avatar for dextrew
Member Avatar for William Hemsworth
0
195
Member Avatar for daviddoria

I have seen some examples like this [code] p.class1 { some stuff } p.class2 {some stuff } [/code] and some like this [code] class1.p {stuff} class2.p {stuff} [/code] In one case, the class name is before the dot, in the other case the class name is after the dot. What …

Member Avatar for daviddoria
0
71
Member Avatar for eedythh2

Yea - this question is clearly a "hello world" type program - they are obviously not getting into stacks yet. You're just confusing the issue instead of adding something constructive...

Member Avatar for daviddoria
0
187
Member Avatar for konata_89
Member Avatar for daviddoria
0
95
Member Avatar for cloudedvision

use the "top" command, and look under the %MEM column... this is a linux question though, not a c++ question. Dave

Member Avatar for StuXYZ
0
101
Member Avatar for elitedragoon

whoa.. that's just asking for trouble. You should make a struct or a class to contain all that information and just pass around 1 variable, not 20! Dave

Member Avatar for elitedragoon
0
172
Member Avatar for shadwickman

you could use a vector instead of an array #include <vector> then you can return a vector<int> and not have to worry about every saying pointer! Dave

Member Avatar for daviddoria
0
347
Member Avatar for Ouais

What type is formGraphics? Are you using some kind of image library or something - ie what are you trying to draw on? Dave

Member Avatar for ddanbe
0
240
Member Avatar for daviddoria

I am very new to css. I was looking at a css file I found online and trying to figure out what everything does. I am confused with the following couple of things. Please let me know if anything I say is wrong! This on sets up some properties of …

Member Avatar for daviddoria
0
147
Member Avatar for robgeek

it looks like your set_add function is expecting you to pass it some values, but then you are reading them in from cin anyway, but then not doing anything with them. Maybe you want something more like this: void addressType::set_add() { cout<<"Enter street address."<<endl; string street; cin>>street; St_address = street; …

Member Avatar for daviddoria
0
111
Member Avatar for daviddoria

Here is my demo.css [code] #sidebar {} #sidebar ul { list-style-image: url(images/bullet.gif); } ul { list-style-type: circle; } [/code] and demo.html [code] <html> <head> <link REL="StyleSheet" TYPE="text/css" HREF="demo.css"> </head> <body> <ul class="sidebar"> <li> Test1</li> <li> Test2</li> </ul> <ul> <li> Test3</li> <li> Test4</li> </ul> </body> </html> [/code] I would expect the …

Member Avatar for daulex
0
443
Member Avatar for daviddoria

I am trying to output 00001 instead of just 1, so I do this: char pos[5]; sprintf(pos, "%05d", 1); string Index = (string) pos; It works just as I'd expect - if I cout << Index it says 00001 However, it is breaking something totally unrelated. On the next line, …

Member Avatar for grumpier
0
224
Member Avatar for daviddoria

Is this flash (how do you tell?) [url]http://www.kwikkopy116.com/[/url] Is there any way to develop a flash site on linux? I've been unable to find anything about it! If not, is there any other way to make a page like this that can be done on linux? Thanks! Dave

Member Avatar for Walkere
0
130
Member Avatar for daviddoria

With printf, you specify the output type like this unsigned char a; printf("%u", a); but with cout, cout << a; there is no type required. Do you have to cast the variable in order to see a reasonable output cout << (int)a; or something like that? How do you know …

Member Avatar for StuXYZ
0
104
Member Avatar for daviddoria

I want to do something like this: unsigned char r[3] = {255, 0, 0}; map<unsigned char[3], int> ColorList; ColorList[r] = 1; But I get the following: error: array used as initializer How else would I set the r element of the map? Thanks, Dave

Member Avatar for daviddoria
0
2K
Member Avatar for daviddoria

I would like to make a list of colors with an associated color index ie 1, [1 0 0] 2, [0 1 0] 3, [.4 .4 .4] etc So I could make a map map <int, double*> ColorMap; Then I could look up the color by its index like this: …

Member Avatar for daviddoria
0
487
Member Avatar for daviddoria

I have a base class called ModelFile I have derived classes called ObjFile and VtkFile that I would like both to use << from ModelFile. However, since << is an external function, [code] ostream & operator << (ostream &output, const ModelFile &Model) { output << "Num Vertices: " << Model.NumVertices() …

Member Avatar for Lerner
0
187
Member Avatar for daviddoria

I would like to declare the type of an object based on user input. Ie. I would like to do the following: [code] string obj = //get from command line arguments if(Format == "obj") { ObjFile Obj; Obj.Read(InputFile); Obj.DoSomething(); Obj.Write(OutputFile); } else if (Format == "vtk") { VtkFile Vtk; Vtk.Read(InputFile); …

Member Avatar for ArkM
0
131
Member Avatar for daviddoria

I've spend a lot of time working on a bunch of classes (point, vector, ray, triangle, plane) etc to work with these objects and their intersections in c++. However, now that I am ready to do a full scale project with them, I am finding they are terribly slow! I've …

0
54
Member Avatar for daviddoria

I have a base class called "ModelFile" which I derive several types of 3D model file classes from. Many of these types of files are just a set of points, so in the base class I have a vector<Point> member. Some of the derived file classes also have vector<Triangle> members. …

Member Avatar for grumpier
0
143
Member Avatar for daviddoria

I have a Triangle class which has members [code] Point P1, P2, P3; [/code] So generally I pass the constructor 3 points. [code] Point A(1,1,1); Point B(1,1,0); Point C(0,0,1); Triangle T(A,B,C); [/code] Then I have a bunch of functions that I can pass point's to such as to find intersections …

Member Avatar for Narue
0
116
Member Avatar for daviddoria

I have done some html many years ago, but never css. I downloaded a template [url]http://www.freecsstemplates.org/preview/exposure[/url] But something has gone slightly wrong. When I use it on my website [url]http://doriad.myrpi.org/[/url] you can see that the bottom "grey" bar is above the blue line, where in the example the grey is …

Member Avatar for MidiMagic
0
81
Member Avatar for daviddoria

Does anyone know how I can count how many times a pdf has been downloaded from my site? Maybe someone has a php script or something that does this? Thanks! Dave

Member Avatar for daviddoria
0
156
Member Avatar for daviddoria

Normally I call this function like this [code] void MouseButton(int button, int state, int x, int y); ... glutMouseFunc(MouseButton); [/code] But now I would like to pass a member function instead of a "real" (non-member? whats the word for this?) function. [code] class Plot { void Plot::MouseButton(int button, int state, …

Member Avatar for kux
0
670
Member Avatar for daviddoria

I need to do something like this: [code] ifstream infile(Filename.c_str()); //ifstream infile(Filename.c_str(), ios::binary); string line; ///////////// Read Header //////////// //read magic number getline(infine, line); while(line[0] == "#") getline(infile, line); MagicNumber_ = line; //more ascii stuff ...... //start reading binary data int m; infile.read(reinterpret_cast < char * > (&m), sizeof(m)); [/code] …

Member Avatar for Narue
0
125
Member Avatar for urbancalli
Member Avatar for ArkM
0
257
Member Avatar for daviddoria

I would like to have a global way to do something like this [code] #ifdef GRAPHICS //do some stuff that relies on graphics libraries that may or may not be installed #endif [/code] The problem with defines is that they have to be defined in every file, or at least …

Member Avatar for daviddoria
0
104
Member Avatar for daviddoria

I have been using GSL, but I find it very awkward to work with. Does anyone have a recommendation for another one to try? I can't seem to find any on google. Thanks, David

Member Avatar for daviddoria
0
155
Member Avatar for daviddoria

It seems that writing ascii files changed significantly from c to c++. It moved from file pointers and things like that to being very easy, like [code] ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file."; myfile.close(); [/code] However, from googling it seems that binary file reading/writing has …

Member Avatar for jencas
0
125
Member Avatar for daviddoria

I have been using vector in c++ lately, but I needed to speed up my code a bit so someone recommended I use regular arrays. My question is 2 part - 1) I thought you couldn't do this!!?? For some reason it is working with no problem? [code] int a=2; …

Member Avatar for ArkM
0
150
Member Avatar for daviddoria

I want to be able to do this: Pass a parameter to my main program like "parallel = yes" and then many functions down in the hierarchy (ie main calls "Function1" which calls "Function2" which calls "Function3", etc) I need to see the value of "parallel". I'd hate to have …

Member Avatar for Radical Edward
0
99
Member Avatar for daviddoria

I have a very simple class [code] class Point { public: Point(); Point(double x, double y); double x_; double y_; } [/code] the problem is, I can't assign my class to another instance, ie: [code] Point A(2,4); Point B(); B = A; [/code] It says the lvalue must be modifiable. …

Member Avatar for Narf!!!
0
213
Member Avatar for daviddoria

I have a function double Max(vector<geom_Point3> &Points, int n); Then in another class, I have a private member: vector<geom_Point3> Vertices_; and in a class function, I call: min_x = Min(Vertices_, 0); however, I get [code] error: qualifiers dropped in binding reference of type "std::vector<geom_Point3, std::allocator<geom_Point3>> &" to initializer of type …

Member Avatar for vijayan121
0
5K
Member Avatar for daviddoria

I am trying to overload * [code] class Vector3 { public: geom_Vector3 operator * (double d);//overload * from the left }; geom_Vector3 operator * (double d, geom_Vector3 &V); //overload * from the right [/code] The problem is this works [code] geom_Vector3 V(1,2,3); cout << -1 * V << endl; [/code] …

Member Avatar for Radical Edward
0
108
Member Avatar for daviddoria

Right now this is my setup: I have these classes Point2 Point3 Vector2 Vector3 Ray2 Ray3 Both Point classes and both Vector are independent. Ray2 contains a Point2 and a Vector2 object, and Ray3 contains a Point3 and a Vector3 object. I have two questions. 1) Should I somehow just …

Member Avatar for Radical Edward
0
115
Member Avatar for zoner7
Member Avatar for daviddoria

I have a function Scan.MakeLinearGrid() which returns a vector<vector<Vector3> > I have another function that is made to accept this type of thing: Scan.setAngleList(vector<vector<Vector3> >); But if I call it like this: [code] Scan.setAngleList(Scan.MakeLinearGrid()); [/code] it says [code] error: initial value of reference to non-const must be an lvalue Scan.setAngleList(Scan.MakeLinearGrid()); …

Member Avatar for Duoas
0
1K
Member Avatar for daviddoria

(see next post for the question about makefiles!) I have this line in ScanScene.h [code] bool ScanScene(LiDARScan &Scan, LiDARScanner &Scanner, vector<geom_Triangle> &Scene); [/code] and in ScanScene.cpp [code] bool ScanScene(LiDARScan &Scan, LiDARScanner &Scanner, vector<geom_Triangle> &Scene) { ... } [/code] then in another file, I [code] #include "ScanScene.h"; int main() { LiDARScan …

Member Avatar for Duoas
0
158
Member Avatar for daviddoria

Is there a way to check for a keypress every time through a loop without forcing a key to be pressed. ie. if you use scanf, the loop will not continue unless a key is pressed. I'd like to say "if a key was pressed, handle it. If not, keep …

Member Avatar for Ancient Dragon
0
82
Member Avatar for daviddoria

Anyone know where I can get an implementation of this? Some code to read in a set of vertices/triangles and then do some simple intersection tests? If you can point me in the right direction that'd be great! Thanks, Dave

Member Avatar for Alex Edwards
0
223
Member Avatar for rpjanaka

make a file using any text editor (emacs, vi, gedit) called test.cpp [code] #include <iostream> using namespace std; double Multiply(double a, double b) { return a*b; } int main() { double c = Multiply(10,2); cout << "10 * 2 = " << c << endl; return 0; } [/code] then …

Member Avatar for daviddoria
0
168
Member Avatar for daviddoria

I have a file that contains lines like: 2/3/4 5/6/7 8/9/10 and I want to extract the 2, the 5, and the 8 So I am parsing the line by the ' ' delmiter to get 2/3/4 5/6/7 8/9/10 then I need to parse each of those to get the …

Member Avatar for Duoas
0
146
Member Avatar for daviddoria

I have about a 1gb data file that needs to be read at the beginning of my program. This takes about 2 minutes to do. I feel like the answer is "no way", but here is my question. In matlab, there is the concept of a "workspace". I can ready …

Member Avatar for Radical Edward
0
95

The End.