227 Archived Topics

Remove Filter
Member Avatar for daviddoria

I have two pages, header.php and sidebar.php which I want to include on several pages using: [code] <?php include 'header.php'; ?> <?php include 'sidebar.php'; ?> [/code] However, there are two different issues. On this page [url]http://ewh.ieee.org/r1/schenectady/New/index.php[/url] , the included text is put BELOW the text on index.php, even thought it …

Member Avatar for daviddoria
0
89
Member Avatar for daviddoria

Currently at the top of every page I have this: [code] <HTML> <HEAD> <TITLE>Schenectady Section of the IEEE</TITLE> <META NAME='url' CONTENT='http://www.ewh.ieee.org/r1/schenectady/'> <META NAME='author' CONTENT='Authorname'> <META NAME='email' CONTENT='author email'> <META NAME='expires' CONTENT=''> <META NAME='revision-date' CONTENT='6-Sep-1999'> <META NAME='keywords' CONTENT='Schenectady Section'> <META NAME='description' CONTENT='Schenectady Section of the IEEE'> </HEAD> [/code] If I move …

Member Avatar for hielo
0
107
Member Avatar for daviddoria

I have recently taken over as a volunteer webmaster for this website: [url]http://www.ewh.ieee.org/r1/schenectady/newsletter.html[/url] Under the "Schenectady Section News" heading, you can see that there are a bunch of simple pages that all look the same. The current process to add a new one is to copy and paste an old …

Member Avatar for daviddoria
0
120
Member Avatar for daviddoria

I put a simple script: [code] <? php print "Hello world"; ?> [/code] here: [url]http://ewh.ieee.org/r1/schenectady/HelloWorld.php[/url] When I go to the page, I don't see "Hello world" displayed. Does that mean PHP is not enabled on the server? Thanks, David

Member Avatar for daviddoria
0
267
Member Avatar for daviddoria

When trying to pass a template parameter to another template, I am getting an 'invalid template parameter' error. I even tried to force it with 'typename' with no success. Can anyone see what's wrong with this? [code] #include <itkImage.h> #include <itkImageFileWriter.h> #include <itkRescaleIntensityImageFilter.h> template <class T> void WriteImage(typename T::Pointer image, …

Member Avatar for Fbody
0
4K
Member Avatar for daviddoria

If I use a template function with T where T = itk::Image<unsigned char>::Pointer, everything is fine: [code] #include <itkImage.h> class Test { public: template <class T> void Add(T patch); }; template <class T> void Test::Add(T patch) { } int main(int, char*[]) { Test a; itk::Image<unsigned char>::Pointer image; a.Add(image); return EXIT_SUCCESS; …

Member Avatar for daviddoria
0
3K
Member Avatar for daviddoria

I have a line like this: [code] <EMBED SRC="ObtainingAndBuilding_Linux.swf" WIDTH=200 HEIGHT=300</EMBED> [/code] that I want to replace 200 and 300 by the browser window width and height. I found some code like this which correctly gets and displays the width and height: [code] <HTML> <head> <script> function showWH(){ if (document.all){ …

Member Avatar for daviddoria
0
141
Member Avatar for daviddoria

I have a folder A with files 001.jpg, 002.jpg, etc I also have a folder B with different files but with the same names; 001.jpg, 002.jpg, etc I want to put all the files in the same directory - is there something that will automatically rename them or something so …

Member Avatar for MaroBey
0
170
Member Avatar for daviddoria

After reading some tutorials it looks like this is how to embed a video with html5: [code] <html> <body> <video width="560" height="340" controls> <source src="big_buck_bunny.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> </video> </body> </html> [/code] (That video is in the same directory has the .html file) When I do this, I see the …

Member Avatar for hindlist
0
92
Member Avatar for daviddoria

In the past when I've done this: [code] int function(int a) { if(a == 2) { return true; } else { return false; } } [/code] the compiler has complained that the function may not return a value. I've fixed this by adding: [code] int function(int a) { if(a == …

Member Avatar for mrnutty
0
220
Member Avatar for daviddoria

I just learned about heaps today. It looks like STL wants you to create a heap by first creating a vector, then using make_heap from <algorithm>: [code] std::vector<SimpleClass> Numbers(8); // ... populate ... // convert Numbers into a heap make_heap(Numbers.begin(), Numbers.end()) ; [/code] Why is there not a <heap> just …

Member Avatar for Narue
0
106
Member Avatar for daviddoria

Can anyone explain why the last line works? It seems like it is trying to cast a CRectangle as a CTriangle (which I imagine should fail?) but it outputs "5" as the function should. [code] // virtual members #include <iostream> using namespace std; class CPolygon { protected: int width, height; …

Member Avatar for mitrmkar
0
118
Member Avatar for daviddoria

Can anyone explain why this would fail: [code] assert(cap >= 0); [/code] But this passes? [code] if(cap < 0) { exit(-1); } [/code] That is, the assert is triggered, but if I replace it with conditional, the exit() function is never called. Thoughts? Thanks, David

Member Avatar for daviddoria
0
88
Member Avatar for daviddoria

Can anyone explain why this doesn't work? [code] #include <iostream> class Parent { public: virtual int Add(int a, int b) = 0; int Add(int a) { return this->Add(a,a); } }; class Child : public Parent { public: int Add(int a, int b) { return a+b; } }; int main() { …

Member Avatar for mike_2000_17
0
219
Member Avatar for daviddoria

I am trying to remove the need to #include stl elements in my header (a requirement for a project I work on). I wrote a "wrapper" for std::vector called "MyVector". I declare a pointer to a MyVector as a member of MyClass. Then when I try to use this in …

Member Avatar for daviddoria
0
262
Member Avatar for daviddoria

I posted a while back about how to overload << It seems all the examples online have the second argument as const, ie [code] ostream & operator << (ostream &output, const Point &p); [/code] but if I have a member function that simply returns a double [code] double Point::getX() { …

Member Avatar for daviddoria
0
196
Member Avatar for daviddoria

With std::queue I've been using this: [code] std::queue<int>::iterator pos = std::find( q.begin(), q.end(), 5); [/code] But when I try that with std::stack : [code] std::stack<int>::iterator pos = std::find( s.begin(), s.end(), 5); [/code] I get [code] error: ‘iterator’ is not a member of ‘std::stack<int, std::deque<int, std::allocator<int> > >’ [/code] Anyone know …

Member Avatar for AuburnMathTutor
0
5K
Member Avatar for daviddoria

I hear perl is the way to go for string parsing, so here is the test! I have a file like this: [code] ... <li><a href="DSC_9866.JPG"> DSC_9866.JPG</a></li> <li><a href="DSC_9867.JPG"> DSC_9867.JPG</a></li> ... [/code] and I want to get a list of the file names. That is, the result I want is …

Member Avatar for daviddoria
0
90
Member Avatar for daviddoria

Hi all, I have started a wiki that I hope to make the "unofficial Daniweb wiki". Its mission is to present short, compilable answers to many commonly asked questions here on the forum. [url]http://programmingexamples.net[/url] I have seeded it with a handful of basic operations. Please feel free to edit, add …

Member Avatar for Bench
4
151
Member Avatar for daviddoria

I've seen that a vector can be sorted using [code] vector<double> V; vector<int> Index; V.push_back(9); V.push_back(10); V.push_back(8); Index.push_back(0); Index.push_back(1); Index.push_back(2); sort(V.begin(), V.end()); [/code] If I want to sort Index according to how V was sorted, there is an optional third parameter to sort() that will do this. I don't understand …

Member Avatar for daviddoria
0
2K
Member Avatar for daviddoria

I've seen a few posts on here talking about "databases" as if they were just files and using fstream to manipulate the file pointer, etc. I'm familiar with SQL, so it would be nice to simply be able to execute sql command (as can be done from vb.net) such as: …

Member Avatar for tesuji
0
235
Member Avatar for daviddoria

(I posted this in the "Geeks Lounge" but didn't get any responses - maybe there'll be better luck here?) Hi all, I was wondering if anyone one could point me to (if they exist) some places to nominate people for enormous contributions to open source and open source philosophy? There …

Member Avatar for popin
0
405
Member Avatar for daviddoria

I'm having a bit of trouble with dynamic_casting. I need to determine at runtime the type of an object. Here is a demo: [code] #include <iostream> #include <string> class PersonClass { public: std::string Name; virtual void test(){}; //it is annoying that this has to be here... }; class LawyerClass : …

Member Avatar for daviddoria
0
71
Member Avatar for daviddoria

I have some white text I am putting over a very light background. Is there anyway to outline the text in black? After some googling it looks like there are some pretty complicated solutions, but I am looking for something like a check box that says "outline". Is there such …

Member Avatar for daviddoria
0
1K
Member Avatar for daviddoria

I set the .Interval of a timer to "10", which I believe means 10 milliseconds. Since there are 1000 ms in 1 second, if I count to 100, I should have 1 second, right? The problem is, if I use a physical stop watch and compare it to my program, …

Member Avatar for kvprajapati
0
271
Member Avatar for daviddoria

Some of you may have noticed that I am always harping about "abstracting the problem" and "posting the smallest compilable piece of code that demonstrates a problem." I rambled a bit about why this is important if anyone cares to read: [url]http://daviddoria.blogspot.com/2010/05/problem-abstraction-helping-others-help.html[/url] Dave

Member Avatar for Ketsuekiame
0
90
Member Avatar for daviddoria

Consider these functions: [code] void OperateOnDoublePointer(double* a) { std::cout << a[0] << std::endl; } void OperateOnFloatPointer(float* a) { std::cout << a[0] << std::endl; } [/code] This works as expected: [code] double* c = new double[1]; c[0] = 3.3; OperateOnDoublePointer(c); [/code] but when I try to do this: [code] double* c …

Member Avatar for Narue
0
2K
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

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

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

The End.