1,177 Posted Topics

Member Avatar for suutukil

I don't see any code there that is adding numbers? Just input and output... Also, please use code tags.

Member Avatar for mrnutty
-1
156
Member Avatar for daviddoria

I made 2 classes, Point and Point3D: Point.h: [code] #ifndef POINT_H #define POINT_H #include <iostream> template <typename T> class Point { protected: T X,Y,Z; public: Point(const T x, const T y, const T z) : X(x), Y(y), Z(z) {} T getX() {return X;}; T getY() {return Y;}; T getZ() {return …

Member Avatar for DdoubleD
0
540
Member Avatar for azjherben
Member Avatar for daviddoria
0
114
Member Avatar for Bladtman242

This seems to work fine for me... [code] #include <iostream> #include <fstream> using namespace std; void skrivtilfil (string placering); void laesfrafil (); int main() { int ioro; cout << "in or out? "; cin >> ioro; if (ioro == 1) { std::cout << "Pressed 1. " << std::endl; } else …

Member Avatar for Bladtman242
0
534
Member Avatar for lancevo3

You don't seem to have posted the whole code - there are errors on line 75 but you've only posted 35 lines!

Member Avatar for mrnutty
0
105
Member Avatar for AssaultM16

You have to create the array in the scope that you are going to use it! Probably the way to go here is have the retrieve() function accept a pointer to the array it will fill. Also, be careful not to use element 4 of an array[4] - it has …

Member Avatar for AssaultM16
0
105
Member Avatar for daviddoria

This may be a gdb problem or a KDevelop problem, but I'm hoping it's a c++ problem so it's more easily fixed! If I "execute" my application either in KDevelop or from a terminal, it finishes and terminates without any problems. However, if I step through the code, when it …

Member Avatar for mrnutty
0
151
Member Avatar for daviddoria

I have written a small program (it depends on big libraries, so I will not post the actual code) that performs correctly, but segfaults at the very end (main return). [code] int main() { ..... my code here... std::cout << "Finished." << std::endl; return 0; } [/code] I see "Finished." …

Member Avatar for NicAx64
0
2K
Member Avatar for daviddoria

If I have a class in a namespace, like this: [code] #ifndef MyClass_h #define MyClass_h namespace NyNamespace { class MyClass { public: typedef double MyType; MyType Read(); }; } #endif [/code] And the implementation: [code] #include "MyClass.h" namespace MyNamespace { MyClass::MyType MyClass::Read() { MyClass::MyType A; return A; } } [/code] …

Member Avatar for daviddoria
0
232
Member Avatar for ScienceNerd

I actually never understood why you would need to use an else-if... it seems that you should only ever hit one of the "else if"s , so if you just had several "if"s you would only hit one of them too, right?

Member Avatar for tux4life
0
143
Member Avatar for BlackPhoenix
Member Avatar for daviddoria

When someone sends a very high resolution image to an account that is received by Outlook 2003, the behavior is to show you the image at its correct resolution, which sometimes only lets you see a very small part of it. Is there a way to set the client to …

0
56
Member Avatar for daviddoria

I installed Office 2003 on a computer, as I have done a zillion times. I setup outlook to get pop3 mail. When I click send/receive - it says sending - complete, receiving - complete, but it does not actually get any of the mail. I tried with outlook express and …

Member Avatar for Suspishio
0
60
Member Avatar for DarkNova

I found this: Use std::vector<T>().swap( c ) to free vector memory it seems to work!

Member Avatar for ggsddu
0
2K
Member Avatar for osan
Member Avatar for chaithanyap

1) use code tags! 2) include<iostream> instead of <iostream.h> 3) don't use conio.h (replace getch() with cin.get(); ) 4) prefix cin and cout with std::

Member Avatar for chaithanyap
0
129
Member Avatar for daviddoria

I have an abstract class NetworkTest and some derived classes PingTest, SMTPTest, and POP3Test. Each Test class overrides a Run() function and has it's own private member variables. I have a txt file for each type of test - ping.txt, pop3.txt, smtp.txt that defines the tests that should be run, …

Member Avatar for daviddoria
0
68
Member Avatar for daviddoria

I have a superclass NetworkTest and 3 derived classes PingTest, Pop3Test, SMTPTest. I want to create a big list of all the tests, like this: [code] Dim Tests As New List(Of NetworkTest) Dim PingTests As List(Of PingTest) = ReadPingTestsFromFile(PingFile) Tests.AddRange(PingTests) Dim Pop3TestResults As List(Of Pop3Test) = ReadPOP3TestsFromFile(POP3File) Tests.AddRange(Pop3TestResults) Dim SMPTTests …

Member Avatar for daviddoria
0
126
Member Avatar for tatainti55

For me, load_files() is returning false - because I don't have background.png in my directory - is that your problem too? If not, can you step into the code with a debugger and tell us when it's crashing?

Member Avatar for daviddoria
0
200
Member Avatar for tazboy

That won't work. [code] class person { protected: string fname, lname, gender bdate; public: person(); // getters and setters }; class student: public person { private: std::string major, grade; //note the std:: qualifier public: student(std::string new_major, std::string new_grade); // getters and setters (aka accessors and mutators) } //------------ implementation file: …

Member Avatar for Stefano Mtangoo
0
135
Member Avatar for atch

[quote]I always thought that order of members in class is without any importance but here I see something different or I'm doing something wrong? [/quote] In some patterns the order that you define variables is important. For example, when you initialize member variables in an initialization list: [code] class MyClass …

Member Avatar for jesseb07
0
107
Member Avatar for daviddoria

I know you can't usually define things in the class like this: [code] class MyClass { double DefaultForward[3] = {0.0, 1.0, 0.0}; }; [/code] but I have some values that don't really make sense to set in the constructor - they are more "deeply connected" as THIS SHOULD ALWAYS BE …

Member Avatar for daviddoria
0
152
Member Avatar for lotrsimp12345

I'm not sure what you're asking for help with, but you would want to overload << and >> so you could do something like this: [code] class A { int a,b; }; int main() { A MyA; cin >> A; //instead of /* int a , b; cin >> a …

Member Avatar for lotrsimp12345
0
244
Member Avatar for daviddoria

(As a warning - if at any point you think "umm why don't you just use X to get your 2 column display - I'm all for that! This is the only way I came up with). I want to end up nice looking display of data on the form …

Member Avatar for daviddoria
0
1K
Member Avatar for licktress

There is quite a bit of overhead, but you can use some of the VUL functions of VXL.

Member Avatar for Ancient Dragon
0
219
Member Avatar for Lfmoncur

@Salem Why would you use spaces instead of tabs? I never understood that, I always set it to tabs - then one keystroke/character replaces several, no?

Member Avatar for Salem
0
121
Member Avatar for JackDurden

You'll have to post a bit more complete code. What is 'input'? Why is 'elements' empty? Please give us an example input, the current (incorrect) output, and the expected output. Also, maybe std::string is better suited for what you're trying to do? Dave

Member Avatar for Ancient Dragon
0
187
Member Avatar for JackDurden

In that sample code, pointer_name should really be vector_name, no? And pointer_name should be of type std::vector<std::vector<<char *> >, no? And what is 'list'? [code] void Create_Pointers(std::vector<std::vector<char *> > pointer_name) { std::vector<char *> NewVector; pointer_name.push_back(NewVector); } [/code]

Member Avatar for daviddoria
0
120
Member Avatar for daviddoria

There is a pure virtual const function declared like wayyyy up the inheritance hierarchy that I need to override, but I would like to override it with a non-const function. I tried and it just complained that the pure virtual const function const was not implemented. I got around it …

Member Avatar for daviddoria
0
419
Member Avatar for farhan.foxtrot

getch() is a c language thing: [url]http://www.daniweb.com/forums/thread11811.html[/url] I think that book was wanting you to include conio.h, but as you will see if you are working in c++ you likely shouldn't be using that.

Member Avatar for 9868
0
185
Member Avatar for Lfmoncur

What is the problem? It looks like you have a pretty good start. I typically read all the lines of a file like this: [code] void VectorOfLines(const std::string &Filename) { std::ifstream fin(Filename.c_str()); if(fin == NULL) std::cout << "Cannot open file." << std::endl; std::vector<std::string> Lines; std::string line; while(getline(fin, line)) { Lines.push_back(line); …

Member Avatar for daviddoria
0
108
Member Avatar for bharatsinh

@bharatsinh - do you want an actual matrix object that can be multiplied, decomposed, etc? If so, you'll probably be best off using a big library like VXL. If you just want to output the numbers to the screen you can use thug line's code as a template. Also, I'm …

Member Avatar for mrnutty
0
144
Member Avatar for DaBunBun

I always advocate using an std::vector when possible.. can you do this: [code] std::vector<int*> yourVar(8); [/code]

Member Avatar for tux4life
0
163
Member Avatar for daviddoria

I frequent the c++ forum, and I've seen quite a number of posts that are about windows api/MFC stuff. This seems to be quite a separate thing than just "c++". Would it make sense to add a new forum to separate it? Dave

Member Avatar for NicAx64
0
203
Member Avatar for shaneera

You cannot just post a bunch of code and expect us to do your assignment. 1) use code tags so the code you do post is readable 2) extract the problem you are having in to the smallest example possible ( < 20 lines) with sample input, expected output, current …

Member Avatar for crunchie
0
197
Member Avatar for Divinginthesky

Yup, sounds like the folder you are working in is not on your PATH. You can either use ./program, or you can add the working directory to your PATH by putting this in your ~/.bashrc file: [code] export PATH=$PATH:/home/youruser/where_you_are_working [/code]

Member Avatar for zautner
0
106
Member Avatar for 23.12.2012

icode is "inline code", so if you have more than 1 line, it is not INline anymore haha. [icode]return 0;[/icode] tells the OS that the program finished properly - i.e. without errors. [icode]\n[/icode] outputs a new line without flushing the buffer. There are zillions of threads around here discussing how/when …

Member Avatar for 23.12.2012
1
214
Member Avatar for Yaserk88

what type is all_words? Maybe you can post a compilable example and demonstrate the problem with some sample input, the current output, and the expected output?

Member Avatar for Lerner
0
107
Member Avatar for #define:me

No, we will not do your assignment. Give it a shot and we'll certainly help when you have a problem. Or ask specific questions about how to get started.

Member Avatar for Salem
0
120
Member Avatar for daviddoria

I have a class called Scanner which casts rays into a 3d scene and records the resulting intersections. It has the following type of properties: Location (a 3d point) Forward (a 3d vector) Up (a 3d vector) min/max angle (the bounds of where to cast rays) theta/phi step (the directions …

Member Avatar for Tom Gunn
0
121
Member Avatar for VIkhers

I think what you're looking for is: [code] std::string Test = "hello world"; char* NewVar = Test.c_str(); [/code] Although I think you'd be better off using an std::stringstream.

Member Avatar for VIkhers
0
136
Member Avatar for seakayaker

VNL (part of VXL) has several multidimensional optimizers - [url]http://vxl.sourceforge.net/[/url]

Member Avatar for daviddoria
0
141
Member Avatar for dumrat

I agree that it's generally a very bad idea - but if you DO have a good reason, compile with -Wno

Member Avatar for Tom Gunn
0
431
Member Avatar for yara naser

It is much more reasonable to note which statements need to be converted, and then ask google how to convert them. If google doesn't know (!?) then we'll help you.

Member Avatar for necrolin
0
176
Member Avatar for sbala_810
Member Avatar for daviddoria

The problem is on the "MyIter = " line: [code] class OrientedPoint { .... class variables ... std::map<std::string, double> DoubleValues; ..... bool OrientedPoint::getDoubleValue(const std::string &ValueName, double &Value) const { std::map<std::string, double>::iterator MyIter; MyIter = DoubleValues.find(ValueName); [/code] The error produced is: [code] In member function 'bool OrientedPoint::getDoubleValue(const std::string&, double&) const': error: …

Member Avatar for daviddoria
0
6K
Member Avatar for daviddoria

Is there a way (without overloading) to call a function like this [code=cplusplus] GetValue("one"); //AND std::string test("one"); GetValue(test); [/code] The function is simply: [code=cplusplus] int GetValue(const std::string &MyString) { return MyMap[MyString]; } [/code] This overload does the job: [code=cplusplus] int GetValue(const char* MyString) { return MyMap[MyString]; } [/code] But that …

Member Avatar for daviddoria
0
114
Member Avatar for zeus1216gw

What do you mean "return only one of the values"? A function can only return one value, and it looks like yours is... maybe you can give an example input, expected output, and current output?

Member Avatar for zeus1216gw
0
111
Member Avatar for khotso

Please use code tags. You can find what you're looking for here: [url]http://www.learncpp.com/cpp-tutorial/93-overloading-the-io-operators/[/url]

Member Avatar for Ancient Dragon
0
92
Member Avatar for daviddoria

Is there some minimum amount of time that has to pass before thread subscription will "instantly notify" me? For example (and this happens a lot) I post a question, someone answered and I received an email about this answer. Then I replied. Then someone else replied, and I didn't receive …

Member Avatar for daviddoria
0
186

The End.