1,177 Posted Topics
Re: You did not post clear.h as far as I can tell. I STRONGLY encourage you to use the "this" pointer explicitly. e.g. in data::lookup() - [icode] std::ifstream lookup( this->name ); [/icode] instead of [icode] std::ifstream lookup( name ); [/icode] It makes code much more readable. Also, you'll get a bunch … | |
Re: I suggest making the smallest compilable code that demonstrates your problem (< 15 lines). It will help you narrow down where the problem is, and if you still can't figure it out, it will save us massive time helping you debug it. Dave | |
Re: I recommend posting this question here: [url]http://tech.groups.yahoo.com/group/OpenCV/[/url] | |
Re: I don't see main anywhere - can you post everything so we can try to compile it? | |
Re: I suggest you start by stripping the code down to the smallest portion that compiles successfully and add code line by line until it breaks. That should give you some hints about where the problems are. | |
Re: In the constructor, you would probably want to set all of the coefficients to 0. The idea is just that you really NEVER want to have unassigned variables. What if you forgot they were assigned in the read function and tried to access them before that? You would end up … | |
Re: [code] #include <cmath> #include <iostream> int main() { double x1 = 0; double y1 = 0; double x2 = 100; double y2 = 100; std::cout << 180./3.14159 * atan((x2-x1)/(y2-y1)) << std::endl; return 0; } [/code] The answer is 45 not 315 going from (0,0), to (100,100), right? Dave | |
Re: I'd really recommend getting the problem down to a <20 line example that we can look at. Dave | |
Re: I'd agree with the second sentence. I wouldn't say anything about allocating memory. Dave | |
Re: Those are linker errors. You need to go into your project settings and make sure you are linking to COMCTL32.LIB and USER32.LIB. Dave | |
After reading a few tutorials, it looks like this: [url]http://www.rpi.edu/~doriad/Examples/Table/[/url] should make a full (100%) width table. However, the width is actually very small and the table is on the left of the page. Does anyone see what is wrong here? Thanks, Dave | |
Re: That seems to be the least of your problems. You'll notice that this won't compile: [code] #include <iostream> void maxmin(struct ma mx); int main() { return 0; } void maxmin(struct ma mx) { int max=mx.ev[0]; int min=mx.od[0]; for (int i=0;i<10;i++) if (mx.ev[i]>max) max=mx.ev[i]; for (int j=0;j<10;j++) if (mx.od[j]<min) min=mx.od[j]; cout<<"The … | |
This code: [code] #include <iostream> class Parent { int name; class Child { int school; void test() { std::cout << this->name; } }; }; int main(int argc, char *argv[]) { Parent MyParent; return 0; } [/code] Generates this error: [code] error: 'class Parent::Child' has no member named 'name' [/code] Is … | |
I have some code that uses _finite (I think from float.h) that my linker complains is not declared. I think this might be a "windows only" function. Is there an equivalent function that I can call that will work cross platform? Thanks, Dave | |
I am trying to compile some old code a colleague gave me. I have MyClass.h [code] class MyClass { public: static int UseIndex; .... }; #include "MyClass.inl" [/code] MyClass.inl [code] ... int TreeNodeData::UseIndex=1; ... [/code] I am getting: [code] multiple definition of `MyClass::UseIndex' first defined here [/code] I got several … | |
I am trying to get a variable number of arguments in one function, and pass them to another function. I tried this: [code] #include <iostream> #include <stdarg.h> void Function1(unsigned int num, ...); void Function2(unsigned int num, va_list ap); int main(int argc, char *argv[]) { Function1(3, 1, 2, 3); return 0; … | |
When compiling some working code on Fedora 11, I am getting this error: [code] /usr/include/c++/4.4.1/cstdarg:56: error: ‘::va_list’ has not been declared [/code] I am using: [code] [doriad@davedesktop VTK]$ g++ --version g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2) [/code] Does anyone know what the problem could be? Thanks, Dave | |
I am trying to compile some software I found online. I am getting a bunch of these errors: [code] No rule to make target `/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h', needed by `formCluster.o'. Stop. [/code] In the Makefiles, there are certainly lines like this: [code] transform.o: /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h [/code] The errors seem to go away if … | |
I am trying to get some code I found online to compile. It looked like this: [code] #include <iostream> #include <list> using std::list; template <class T> class leda_list : public std::list<T> { private: iterator loopIter; [/code] the error was: ‘iterator’ does not name a type I tried changing it to: … | |
I want to make a type to differentiate degrees and radians. I wanted something like this to produce a compiler error: [code] #include <iostream> typedef double Degree; typedef double Radian; void MyFunction(Radian angle); int main() { Degree foo = 3.0; return 0; } void MyFunction(Radian angle) { std::cout << "Success." … | |
Re: Some libraries that you may find helpful: ITK: [url]http://itk.org/[/url] VIL (part of VXL): [url]http://vxl.sourceforge.net/[/url] OpenCV: [url]http://opencv.willowgarage.com/wiki/[/url] CImg [url]http://cimg.sourceforge.net/[/url] Hope that helps. Dave | |
If I go to: view -> arrange by -> current view -> customize current view -> other settings I can change the "row font" size for the current folder. If I have 100 folders and I want to change the font size for the messages in all of them, you … | |
Why people write such cryptic code I will never understand... Can someone explain what is going on in the following: [code] double color = {1,2,3}; double *ptr; // ... assign ptr .... *ptr = *color++; ptr++; [/code] So this line [icode] *ptr = *color++; [/icode] sets the value of the … | |
Is there a way to see what a macro gets expanded to? I tried to put it in quotes and use printf, but of course printf just printed exactly the string. The result of: [code] #define SetMacro(name,type) \ virtual void Set##name (type _arg) int main() { printf("SetMacro(Test, int)"); } [/code] … | |
A friend of mine has a big table on his website: [url]http://www.rpi.edu/~chens/Research.html[/url] I think it looks great, so I tried to copy this style/code, but it is making too many columns: [url]http://www.rpi.edu/~doriad/TechnicalReports.html[/url] I read [url]http://www.w3.org/TR/html4/struct/tables.html[/url] , but it looks to me like I have done everything right (all it is … | |
I have some sections like: [code] <h3>EngineeringNotes.net</h3> <br>I have never .... [/code] (see this page: [url]http://www.rpi.edu/~doriad/Personal.html[/url]) Why is there such an enormous space between the header and the text? I thought <br> should just insert a single line break? Thanks, Dave | |
Re: Please post the code for the constructor - you have posted only declaration, no definitions, so we can't see what is going on! | |
Consider two classes, PersonClass and LawyerClass. If LawyerClass derives from PersonClass, you can create a PersonClass* as a LawyerClass, like [code] PersonClass* Person = new LawyerClass; [/code] then you can convert it to a LawyerClass* with [code] LawyerClass* Lawyer = static_cast<LawyerClass*>(Person); [/code] However, if you don't know that the person … | |
Say you have a class that has members [code] private: double a,b,c,d,e,f,g,h,i; [/code] You can make an accessor like: [code] double operator[](int index) { if(index == 0) return a; else if(index == 1) return b; else if(index == 2) return c; } [/code] But how would you do something like … | |
If I have the following setup: [code] Point* MyPoint = Object->GetMyPoint(); if(MyPoint->GetValue() != 2) do something; else do something else; [/code] If MyPoint is NULL or invalid, the MyPoint->GetValue() will cause a segfault. This should fix it: [code] Point* MyPoint = Object->GetMyPoint(); if(MyPoint) { if(MyPoint->GetValue() != 2) do A; else … | |
Re: First of all, you should [icode]#include <iostream>[/icode] instead of [icode]#include <iostream.h>[/icode]. This is the "new" c++ way to do it. Second, you have to [icode]#include <cstring>[/icode] to use strcpy. Third, you have not declared getHours in the header file. To show you this, the compiler says: "error: no 'int Person::getHours()' … | |
Re: You need to give us more of a feeling that you have really tried. Did your code produce errors? Or incorrect results? Why don't you try some simple cases like the number '4'. You should expect to see factors of 2 and 2, right? Small examples like these will help … | |
Re: I don't understand why you would want to remove stl features? They make things MUCH easier... | |
Re: I don't understand the problem... [code] int NumberOfPositiveRoots(root1, root2) { int counter = 0; if (root1 >= 0) { counter++; } if (root2 >= 0) counter++; } return counter; } [/code] | |
Re: What you have there is simply a hard coded triangle. You need to write the code to setup the triangle's height and width. Give it a shot and post your problem once you try it. | |
Re: Please explain exactly what you need. What operating system are you using? | |
Is there a "correct" way to draw a line betwee the header and body of a document in word 2007? I've been using a Shapes->Lines line, but it seems silly because there is no way to center it, etc. Any ideas? Thanks, Dave | |
With this code: [url]http://www.rpi.edu/~doriad/Daniweb/maxflow/[/url] If I run [code] g++ Example.cpp graph.cpp [/code] with g++ 3.3, everything works fine. However if I run the same command with g++ 4.4, I get this error: [code] Example.cpp:(.text+0x38): undefined reference to `Graph<int, int, int>::Graph(int, int, void (*)(char*))' [/code] Does anyone know how I can … | |
I have written an integration function (of one variable) [code] double integrate(double (*f)(double), const double a, const double b) [/code] However, now I want to integrate a function of one variable, but the c++ function has an additional parameter: [code] double f(double x, bool flag) { if(flag == true) f … | |
With normal folders, you can right click them and say "Remove from favorite folders, as per here: [url]http://office.microsoft.com/en-us/outlook/HA011176721033.aspx[/url] However, Calendar and Contacts don't have that option. How would one remove them? Thanks, David | |
I am looking at some open source code and I am a bit confused. There is an Allocator class: [code] class Allocator{ [/code] Then in another class, they have: [code] class Octree{ public: static Allocator<OctNode> Allocator; [/code] When trying to compile, I am getting: [code] error: declaration of 'Allocator<OctNode<NodeData, Real> … | |
I am trying to compile some code (Example.cpp from here: [url]http://www.rpi.edu/~doriad/Daniweb/maxflow/[/url]). I am getting [code] Example.cpp:(.text+0x38): undefined reference to `Graph<int, int, int>::Graph(int, int, void (*)(char*))' [/code] This is clearly a template instantiation problem. I see that there is a file called instances.inc that defines the <int,int,int> class, do I need … | |
Is there anyway to get images to be the "correct" size - i.e. fit the width of the text? This is what currently happens: [url]http://engineeringnotes.net/personal/pictures.shtml[/url] Thanks, Dave | |
I'm still very new to css, so I'm sure this is just some really silly thing: [url]http://engineeringnotes.net/personal/[/url] Does anyone know why the text is hanging off the left side of the page (on the "home" page and the "publications" page? Thanks, Dave | |
Re: Please post the smallest compilable example of your problem. "I'm getting errors" doesn't really let us know what is going on. My guess is you need to put "typename" in front of your nested qualifier: [code] typename namespaceOne::namespaceTwo::YourClass A; //instead of //namespaceOne::namespaceTwo::YourClass A; [/code] The later is ambiguous - the … | |
Re: Please show us the code that you've come up with so far and we can help guide you. | |
When debugging my code, I put a break point at this line: [code] std::set<unsigned int>::iterator it; [/code] When I step over that line, I get "Debugger reported the following error: cannot access memory at address 0x10". I am using KDevelop that ships with Fedora 11. I've used that line of … | |
Re: Please use code tags. Also, what is the current (incorrect) output? Also, you don't seem to show where seller, cost etc are defined and given values? | |
I have a function like this: [code] bool MyFunction(dist) { if(dist < 1.2) { std::cout << "Passed test!" << std::endl; return true; } else { std::cout << "Failed test!" << std::endl; return false; } std::cout << std::endl; } [/code] gcc tells me "warning- control reaches end of non-void function". However, … |
The End.