227 Archived Topics
Remove Filter 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 … | |
I have a function: void CreateCostGrid(vector<ScanPoint> &Data, int whichcol, vector<LiDARScan> &LiDARGrid); That I call like this: CreateCostGrid(TestScan.getColumn(GoodCols.at(testcol)), GoodCols.at(testcol), ModelScans); But I get this: error: initial value of reference to non-const must be an lvalue CreateCostGrid(TestScan.getColumn(GoodCols.at(testcol)), GoodCols.at(testcol), ModelScans); (There is an arrow underneath the T in TestScan, i guess indicating that … | |
I'd imagine there is a much better way to do this... [code] vector<double> Model; //code to fill Model vector<double> V1; for(int i = StartModel; i <= EndModel; i++) V1.push_back( Model.at(i) ); [/code] | |
I want to do something like this [code] #include <string.h> #include <iostream> using namespace std; int main() { MyFunc("test"); return 0; } void MyFunc(const char* Filename) { cout << strcat(Filename, ".tst") << endl; } [/code] but it tells me that my const char* cannot be used where it is expecting … | |
This doesn't seem to behave as I would expect (as it does in matlab, for example). I want to execute a command, but give some readable output instead of the often very messy auto-generated error (index out of range or something). [code] try { MyFunction(1,2); } catch(char* str) { cout … | |
I have to call a function in the form f(void* params) I would like to pass two vector<double> to this function. I suppose I should make a struct struct MyParam_t { vector<double> myvector1; vector<double> myvector2; }; and then somehow fill it and pass it to the function. Someone recommended that … | |
I ran this: [code] cout << "has nan q?" << numeric_limits<int>::has_quiet_NaN << endl; cout << "has nan s?" << numeric_limits<int>::has_signaling_NaN << endl; cout << "has nan q?" << numeric_limits<double>::has_quiet_NaN << endl; cout << "has nan s?" << numeric_limits<double>::has_signaling_NaN << endl; [/code] and I get 0 0 1 1 why would … | |
I have some code like this: [code] vector<double> Saved; for(int i = 0; i<10; i++) { if(some condition on i) Saved.push_back(i); } [/code] Then I want to see what order the things were saved... so naturally I do cout << Saved.at(0) << endl << Saved.at(1) << endl; But to my … | |
When trying to compile my code with g++ i get this: MayaFunctions.h:5:27: error: calling fdopen: Bad file descriptor in that line, I simply have #include "AnotherFile.h" Google told me this has something to do with precompiled headers, but I can't figure out how to turn them off. 1) how to … | |
I keep getting this error: this application has failed to start because MFC80.dll was not found. In the past, when I've got this error i've played around with "Runtime library", switching it from /MDd to /MD to /MTd......etc etc then I turn off and on the manifest files then I … | |
I seem to be able to write as many characters as I want into "buffer" even though I declare it as length 1 - why is this? [code] string teststring = "teststring"; cout << teststring << endl; char buffer[1]; itoa(34567,buffer,10); teststring.append(buffer); cout << teststring << endl; [/code] Thanks! Dave | |
I have 2 classes, Edge and Point. Edge contains Point P1 and Point P2 as private memebers. Edge has accessor functions [code] Point getP1() { return P1; } [/code] and the same for P2. Point has << overloaded - [code] ostream & operator << (ostream &output, Point &p); [/code] I … | |
I had a global variable that could be seen by all of my functions. I was getting too many functions in the same file, so I made functions.h and functions.cpp. I put the function definitions in functions.cpp and the declarations in functions.h. In main.cpp, I include functions.h. The problem is, … | |
is there a package for c++ that will allow me to make a matlab/gnuplot style plot from within c++? I would like to skip the step of writing data to a file and then using something else to read in the data and then plot it. Let me know what … | |
I have a class called MyClass in main, I have [code] MyClass A; //calls the default constructor A.date = 4; [/code] I would like a function to do some stuff and then use one of A's constructors , the result being I have A back in main [code] class MyClass … | |
I found _isnan() in float.h for VS2008, but I would like to SET a variable to a NaN intentionally, not check if it is one. Is this possible? Thanks, David | |
I made a library (.lib) with VS2005. Is there a way to convert it to a .a linux library without moving the code and setting up a project and compiling in linux? Thanks, David | |
I am getting a whole bunch of these: warning C4996: 'vsprintf' was declared deprecated see declaration of 'vsprintf' Message: 'This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. I put this at the top of my code: #define _CRT_SECURE_NO_DEPRECATE but nothing changed, I … | |
This is a very general question. I'm sure there is no "right" way so I thought I'd ask for opinions/common practice. In my file MainProgram.cpp (containing main()), sometimes I will have LOTS of functions. It seems very distracting to have a thousand lines of code all in the same file, … | |
I wrote a simple class: c:\geometry\Point.h c:\geometry\Point.cpp I made a VS2005 project and added a Source File test.cpp which contains main(). In test.cpp, I #include "c:/geometry/Point.h" When I build the project I get: Unresolved external symbol "public: __thiscall Point::Point(double,double,double)" referenced in function _main. However, if add Point.h to my Header … | |
Last week I asked about this so I tried to write another example to try it out. I have a Line class which needs to have and members of type Point and member functions that return type Point. The Point class needs to have member functions that return type Line … | |
I am trying to use OPT++ for multidimensional optimization with Visual Studio 2005. I added the include directory to my project. I added the lib directory to my project. When I try to compile the example that ships with the package, i get 102 of the same error: NEWMAT is … | |
I have "right" overloading working fine with: Vector Point::operator*( double P ) this would be called with MyPoint*2 and gives the results I would like. However, if I say: 2*MyPoint, it says I can't do that. Makes sense, but surely this can be done! I had trouble googling because I … | |
I have a class called Point. Point.h : [CODE] #ifndef POINT_H #define POINT_H #include "Vector.h" #include <iostream> class Point { friend ostream& operator<<(ostream& output, const Point& p) //must have global scope { output << "x: " << x << " y: " << y; return output; } [/CODE] The compiler … | |
I have a class Vector that needs to have a function that returns type Point, and a class Point that needs to have a function that returns type Vector. I was informed that I needed to use forward references, which I thought I had implemented as follows. I am still … | |
Is it possible to make a function with an unknown number of parameters without knowing ANY of them? ie. void Test(...) I know you could do void Test(va_alist) with varargs.h, doesn't make sense that this functionality has been removed does it? Thanks! Dave | |
Is there a way to interpolate between RGB values? I have a set of values that I want to map (linearly or otherwise) to colors from a color_min RGB triple to a color_max RGB triple. Since RGB is not "incrementable", how would I do this? Thanks, David |
The End.