1,177 Posted Topics
Re: I'm not sure how to do this, but looks like this is what you want: [url]http://www.devx.com/vb2themax/Tip/18773[/url] | |
Re: You're map is supposed to store a string and a ConfigPaths* , but you are trying to pass it s1 (a string) and m1 (a ConfigPath, NOT a ConfigPath*) I've never used that ::value_type, so I could be wrong, but thats the first thing I'd look at. | |
I have a program with about 20 forms, almost all of which use the data from a tables in a dataset (from a datasource I added to the project). So I have made a global variable in a module: [code] Public TTData As New TTDataSet [/code] And a DataAdapter for … | |
Re: I believe this is generally called tokenizing? Take a look at this - [url]http://www.daniweb.com/forums/thread27905.html[/url] Is that what you were asking? | |
I have a typed datatable that I am viewing part of with a datagridview [code] dgvData.DataSource = TTData.PunchEventTable.Select(FilterString, SortString) [/code] My question is how do I delete the row that is selected in the DataGridView from the database? If I use [code] TTData.PunchEventTable.Rows.RemoveAt(dgvData.SelectedRows(0).Index) [/code] I believe it will delete the … | |
Re: I don't understand the relationship between truck_data and position_axle Maybe give a sample input/output? | |
Re: I always pass things as const if the function will not change them. Also you should pass anything bigger than a single int or double by reference. Both techniques are shown here: [code] int compare(const string &target, const string &s)//outputs # of correct characters { int alike = 0; for … | |
Re: I've never done this, but it doesn't look you passed any arguments? What about [code] system("FileName.exe arg1 arg2"); [/code] | |
Re: Use vectors! [code] #include <vector> int a,b; cin>>a>>b; vector<int> InnerVector(a, 0); vector<vector<int> > OuterVector(b, InnerVector); [/code] | |
I want to do something like this [code] template <class T> vector<T> DereferenceVector(vector<T*> &PointerVec) { vector<T> ObjectVec; for(unsigned int i = 0; i < PointerVec.size(); i++) ObjectVec.push_back(*PointerVec[i]); return ObjectVec; } [/code] and call it with [code] void TestDereferenceVector() { vector<double*> a(10); vector<double> b = DereferenceVector(a); } [/code] That seems to … | |
Re: Yea, I'd guess 'size' is either a "reserved word" (not technically?) - just try to rename the variable and see if that works. | |
Re: Why not try the easy way to read files? [code] ifstream fin(Filename.c_str()); if(fin == NULL) cout << "Cannot open file." << endl; vector<string> Lines; string line; while(getline(fin, line)) { Lines.push_back(line); } cout << "NumLines: " << Lines.size() << endl; for(unsigned int i = 0; i < Lines.size(); i++) cout << … | |
Re: Why not use a vector<string>? Then you can use getline() :) | |
Re: That is a linker error - you'd have to setup your project to compile linestorage.cpp. | |
Re: Why would you ever use a pointer to a pointer? Seems like its just asking for problems? | |
Re: It may be because you have a semicolon at the end of this line: [code] while(mod_number2 = i%1); [/code] Try removing that. Also, please use [ CODE ] tags around your code - what you posted was very difficult to read. Dave | |
Re: That is like saying ok I want to talk to this guy in French... I know he is French... now what do I do? | |
Re: You will need to use the c_str() function of the string because a lot of these function accept an array of characters, not an actual string. [code] #include <string> using namespace std; string filename = "whatever.txt"; fstream fio(filename.c_str(), ios::in | ios::out | ios::binary | ios::trunc); [/code] Dave | |
Re: I rarely need to use it. If you are within the scope of the class, MyVariable is the same as this->MyVariable. It is sometimes just nice for other people that read your code so that they know where these variables reside. Dave | |
Re: I use openGL with SDL ([url]http://www.libsdl.org/)[/url]. Be careful, there is quite a learning curve! | |
If I do this, I get "warning: address of local variable returned". [code] unsigned char* CharArray(void) const { unsigned char arr[3]; arr[0] = R_; arr[1] = G_; arr[2] = B_; return arr; } [/code] So the reason for that is that the memory allocated for arr[] is only available within … | |
Re: Give it a try and then we'll help. | |
Re: This is called casting. The c++ style way to cast is [code] total_gal_paint = static_cast<int> ( (total_area / coverage_gallon_paint) + (0.9999) ); [/code] The code DemonGal711 posted is exactly the same thing as far as I know, its just a little "c style" :) Also, it would be much easier … | |
Re: You should post only problematic section of the code, not the entire file! [code] getline(istream& fin, string& num_of_isbn, char '\n'); [/code] You need declare these variables and then pass them to the function, ie [code] istream fin; string num_of_isbn; char a; getline(fin, num_of_isbn, a); [/code] The & will be in … | |
Re: I would search for boostnb.h or boostnb.cpp, because boostnb.o won't be made until you compile boostnb.cpp into the .o ! Also, please use code tags for only the code! | |
Re: That is a linking error. You need to either link to the library, ie [code] g++ yourfile.cpp -l lTheLibrary [/code] or actually compile the source along with yours (if you have it) [code] g++ yourfile.cpp TheFileTheFunctionIsIn.cpp [/code] Unfortunately, this sounds like a big set of libraries and they are usually … | |
Re: You may want to simplify the question to a single case. Once you get an answer you should be able to apply it to the rest of the cases. It just is overwhelming to people reading to look at 1000 lines of code that you post. Also, please wrap the … | |
A friend convinced me to store a vector of pointers in my class: [code] vector<Point*> Points; [/code] In my class instead of a vector of "real" objects (what do you call this?). The problem now is that there are several functions (out of my control ie. in a library) that … | |
I have a function that I call recursively, but I want to keep track of a maximum through the entire process. This is what I am doing: [code] void Intersect(double &MaxDistance) { if(something) MaxDistance = something; Intersect(MaxDistance); } [/code] Is that correct/reasonable? Something doesn't seem to be working and I'm … | |
There was another thread about this ([url]http://www.daniweb.com/forums/thread114737.html[/url]) but it didn't seem to be resolved? If I have a vector of int's and another vector of the same length of corresponding names, I would like to sort the ints and have the names "follow" [code] vector<string> Doubles; Doubles.push_back("Name1"); Doubles.push_back("Name2"); Doubles.push_back("Name3"); vector<int> … | |
Re: You should simplify the problem. This problem has nothing to do with a bank, so why mention a bank? Ask something like [quote] I want to input a line like "MyName 2.3 4.5 6.7" and store the input in a string and 3 doubles. How do I do that? [/quote] … | |
[code] double P = 3.5/(.1 * sqrt(2.0*3.14159)) * exp(-pow(5.0,2) / (2.0*pow(.1,2))); cout << P << endl; if (P==0) cout << "P is zero!" << endl; [/code] Is this underflowing so it is getting rounded to zero? The problem is that I am taking the log of this, so if it … | |
I wrote a pause function: [code] void Pause(void) { printf("Paused...\n\n"); fgetc(stdin); } [/code] It generally works fine (hit enter to continue). But one program doesn't seem to want to stop at all... [code] if(P == 0) { cout << "P=0!" << endl; //just as another attempt to stop it , … | |
Is there anyway to get the calling function? ie [code] void A() { if (A() was called from B() ) do something; else do something else } [/code] Is this possible? Dave | |
In integration.h I have this [code] class FunctionClass { public: virtual double f(const double x) = 0; }; [/code] Then in probability.h, I have this [code] #include "integration.h" class Mass1 : public FunctionClass { public: double Clutter; Mass1(double c) : Clutter(c) {} double f(const double x) { return Clutter * … | |
I just learned about returning a reference... and it seems to me that I can delete my mutators now? ie. [code] class foo { int A; //mutator void set_A(const int a) {A=a;} //accessor int get_A() {return A;} } int main() { foo MyFoo; int b = MyFoo.get_A(); //get MyFoo.set_A(4); //set … | |
I would expect this to ouput the 5 doubles, but instead I get the output below. [code] vector<double> a(5); a.push_back(1.2); a.push_back(1.3); a.push_back(1.4); a.push_back(1.5); a.push_back(1.6); vector<double>::iterator i; i = a.begin(); while( i != a.end() ) { cout << *i << endl; i++; } [/code] [code] 0 0 0 0 0 1.2 … | |
Anyone know a good, simple set of classes to do thing like cartesian to spherical conversion, coordinate system transformations, etc? I wrote some of this stuff, but my code keeps breaking because of "special cases" that I have not handled. I just want to be able to use this stuff … | |
I put together this little example to test my sanity, and it failed! [code] #include <iostream> #include <fstream> #include <vector> #include <string> #include <sstream> using namespace std; /* Example.txt 23 test 4.5 */ int main(int argc, char *argv[]) { string Filename = argv[1]; cout << "Filename: " << Filename << … | |
Anyone see a problem with this line? My Color header is included (I use it all the time). map and vector are included. [code] void GenerateColors(map<Color<unsigned char>, int> &Map, vector<Color<unsigned char> > &List, int num) [/code] I don't see anything wrong? Dave | |
This problem comes up quite a bit for me. I'll have a project that I work on for a couple months (the point is that it is a large project with multiple classes, etc). As an example, say I made a program that draws a square. So I have this … | |
Re: 1) make sure you open the file in append mode in the add() function (i'm not sure what the default mode is) 2)there is no need to do [code] while (!a.eof()){ getline(cin, line); [/code] you can simply do [code] while(getline(cin,line)) [/code] If you don't tell us what's wrong, we can … | |
Re: There's a really easy to use timer in VUL (part of VXL). It may be a bit of overhead to install it, but it works great once it's installed. Dave | |
Re: Is there a way to remove these threads altogether? It really pollutes the forums. Dave | |
Re: Debug symbols are needed if you are trying to debug though! If by profiling you mean something like cachegrind, that will be VERY slow... (maybe 50x slower?), but you get an unbelievable view of any bottlenecks in your code. Dave | |
Re: You may look into some kind of library for working with videos. I think VXL ([url]http://vxl.sourceforge.net/[/url]) has a VIDL library for working with videos. VTK also can do things with videos ([url]http://www.vtk.org/doc/nightly/html/classvtkFFMPEGWriter.html[/url]) Good luck! Dave | |
Re: Is this being done with some external program? I wasn't aware c++ could upload files... lol | |
Re: Please wrap your code in code tags. I think you have to explicitly define an update command for the data adapter. | |
Re: I agree, I have been unable to find anything good about this so far! |
The End.