265 Discussion / Question Topics

Remove Filter
Member Avatar for daviddoria

I am trying to parse the content of a wiki page. In a string like this: [code] ==Heading1== <test> some text here </test> ==Heading2== <test> even more text </test> [/code] I need to obtain "Heading1", "some text here", "Heading2" and "even more text". I got this to work: [code] import …

Member Avatar for daviddoria
0
15K
Member Avatar for daviddoria

I am trying to strip a prefix from a string, e.g. turn [code] VTK/Examples/Test [/code] Into [code] Test [/code] Sometimes the string does not contain the prefix, in which case I would expect nothing to happen. However, [code] >>> S="Main Page" >>> S.strip("VTK/Examples/") 'Main Pag' [/code] You can see that …

Member Avatar for woooee
0
155
Member Avatar for daviddoria

Is there a data structure that lets me push and pop things onto/off of a queue, but also doesn't allow duplicates? E.g. I want [code] queue a; a.push(1); a.push(2); a.push(2); a.push(3); [/code] to only have 3 elements, because 2 was added twice so the second time it is just ignored. …

Member Avatar for mattjbond
0
168
Member Avatar for daviddoria

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

Member Avatar for almostbob
0
102
Member Avatar for daviddoria

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 …

Member Avatar for HealBrains
0
174
Member Avatar for daviddoria

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

Member Avatar for daviddoria
0
216
Member Avatar for daviddoria

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 …

Member Avatar for daviddoria
0
221
Member Avatar for daviddoria

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; …

Member Avatar for daviddoria
0
234
Member Avatar for daviddoria

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

Member Avatar for daviddoria
0
1K
Member Avatar for daviddoria

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 …

Member Avatar for daviddoria
0
403
Member Avatar for daviddoria

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: …

Member Avatar for daviddoria
0
272
Member Avatar for daviddoria

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." …

Member Avatar for Narue
0
109
Member Avatar for daviddoria

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 …

0
955
Member Avatar for daviddoria

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 …

Member Avatar for kvprajapati
0
131
Member Avatar for daviddoria

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] …

Member Avatar for daviddoria
0
138
Member Avatar for daviddoria

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 …

Member Avatar for almostbob
0
74
Member Avatar for daviddoria

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

Member Avatar for daviddoria
0
67
Member Avatar for daviddoria

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 …

Member Avatar for daviddoria
0
5K
Member Avatar for daviddoria

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 …

Member Avatar for Narue
0
97
Member Avatar for daviddoria

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 …

Member Avatar for JasonHippy
0
122
Member Avatar for daviddoria

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

0
66
Member Avatar for daviddoria

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 …

Member Avatar for StuXYZ
0
132
Member Avatar for daviddoria

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 …

Member Avatar for mrnutty
0
280
Member Avatar for daviddoria

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

Member Avatar for caperjack
0
236
Member Avatar for daviddoria

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> …

Member Avatar for StuXYZ
0
107
Member Avatar for daviddoria

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 …

Member Avatar for dkalita
0
393
Member Avatar for daviddoria

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

Member Avatar for Troy III
0
134
Member Avatar for daviddoria

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

Member Avatar for daviddoria
0
175
Member Avatar for daviddoria

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 …

Member Avatar for Nick Evan
0
3K
Member Avatar for daviddoria

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, …

Member Avatar for StuXYZ
0
276
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 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 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 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 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 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 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 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 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 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 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
Member Avatar for daviddoria

I don't understand why can you do this: [code] Employee *emp; if (condition1) emp = new Employee(); else if (condition2) emp = new Manager(); [/code] but not this: [code] Employee emp; if (condition1) emp = Employee(); else if (condition2) { emp = Manager(); [/code] Maybe this is a TERRIBLE idea, …

Member Avatar for Ancient Dragon
0
96
Member Avatar for daviddoria

I'm trying to start writing tests for all of my functions as per Test Driven Development. My question is, say I construct a test for "rotate vector". It would be something like this: [code] int TestRotateVector(const Vector &V) { Vector Original(1.0, 2.0); Vector Rotated = Original.Rotate(10); //rotate 10 degrees if(Rotated …

Member Avatar for StuXYZ
0
186
Member Avatar for daviddoria

i.e. [code] class A { int x = 5; }; [/code] I saw a mailing list post from October 08 where a guy asked if this was going to be added. gcc 4.4 was released April 09, so I would assume it would have been added by then? I haven't …

Member Avatar for Ancient Dragon
0
162
Member Avatar for daviddoria

If I do something like this: [code] print "%08d" % 2 [/code] It will print '00000002'. However, I want to change the "8" to a "3" at runtime (to get '002' instead). I tried this: [code] MyLength = 3 print "%0" + str(MyLength) + "d" % 2 [/code] but I …

Member Avatar for daviddoria
0
138

The End.