1,177 Posted Topics
Re: I don't see any code there that is adding numbers? Just input and output... Also, please use code tags. | |
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 … | |
Re: Can you provide the shortest possible compilable example that produces the error ? | |
Re: 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 … | |
Re: You don't seem to have posted the whole code - there are errors on line 75 but you've only posted 35 lines! | |
Re: 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 … | |
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 … | |
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." … | |
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] … | |
Re: 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? | |
Re: From what I've seen OpenGL is the way to go. Dave | |
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 … | |
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 … | |
Re: I found this: Use std::vector<T>().swap( c ) to free vector memory it seems to work! | |
Re: Please use code tags! | |
Re: 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:: | |
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, … | |
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 … | |
Re: 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? | |
Re: 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: … | |
Re: [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 … | |
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 … | |
Re: 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 … | |
(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 … | |
Re: There is quite a bit of overhead, but you can use some of the VUL functions of VXL. | |
Re: @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? | |
Re: 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 | |
Re: 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] | |
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 … | |
Re: 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. | |
Re: 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); … | |
Re: @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 … | |
Re: I always advocate using an std::vector when possible.. can you do this: [code] std::vector<int*> yourVar(8); [/code] | |
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 | |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: 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? | |
Re: 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. | |
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 … | |
Re: 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. | |
Re: VNL (part of VXL) has several multidimensional optimizers - [url]http://vxl.sourceforge.net/[/url] | |
Re: I agree that it's generally a very bad idea - but if you DO have a good reason, compile with -Wno | |
Re: 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. | |
Re: What made you think to ask this in a c++ forum?? haha | |
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: … | |
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 … | |
Re: 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? | |
Re: 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] | |
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 … |
The End.