Search Results

Showing results 1 to 40 of 555
Search took 0.16 seconds.
Search: Posts Made By: daviddoria ; Forum: C++ and child forums
Forum: C++ 9 Days Ago
Replies: 7
Views: 251
Posted By daviddoria
Sorry, this was a typo - should be:
double color[3] = {1,2,3};

// ... assign ptr .... meant do something like ptr = GetAValidPointer()

The part I was concerned with is the following. I was...
Forum: C++ 9 Days Ago
Replies: 7
Views: 251
Posted By daviddoria
Why people write such cryptic code I will never understand...

Can someone explain what is going on in the following:


double color = {1,2,3};

double *ptr;
// ... assign ptr ....
Forum: C++ 13 Days Ago
Replies: 2
Views: 142
Posted By daviddoria
Very cool - thanks!
Forum: C++ 13 Days Ago
Replies: 2
Views: 142
Posted By 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:

#define...
Forum: C++ 21 Days Ago
Replies: 5
Views: 319
Posted By daviddoria
I ended up having to create a LawyerClass object and then copying in the data from the PersonClass. Thanks for the discussion/help!
Forum: C++ 23 Days Ago
Replies: 5
Views: 319
Posted By daviddoria
Consider two classes, PersonClass and LawyerClass.

If LawyerClass derives from PersonClass, you can create a PersonClass* as a LawyerClass, like

PersonClass* Person = new LawyerClass;


then...
Forum: C++ 33 Days Ago
Replies: 1
Views: 221
Posted By daviddoria
Say you have a class that has members

private:
double a,b,c,d,e,f,g,h,i;


You can make an accessor like:

double operator[](int index)
{
Forum: C++ Nov 10th, 2009
Replies: 4
Views: 183
Posted By daviddoria
Jas, but won't it still crash evaluating the second part of the conditional?

Dave
Forum: C++ Nov 10th, 2009
Replies: 4
Views: 183
Posted By daviddoria
If I have the following setup:



Point* MyPoint = Object->GetMyPoint();

if(MyPoint->GetValue() != 2)
do something;
else
do something else;
Forum: C++ Nov 5th, 2009
Replies: 4
Views: 244
Posted By daviddoria
From that algorithm you gave I don't understand how you are supposed to get more than one factor?

Maybe this will be a good starting point for you - it just gets the smallest factor (besides 1)...
Forum: C++ Nov 5th, 2009
Replies: 3
Views: 214
Posted By daviddoria
Is this what you are looking for?


#include <iostream>
#include <string>

int main()
{
const char NONWORD[] = "\n";
Forum: C++ Nov 5th, 2009
Replies: 6
Solved: Triangle.
Views: 262
Posted By daviddoria
Here you have declared the variables, but then output just constant expressions...

I'd suggest googling for "basic c++" and trying some of the simple examples you find until you get familiar with...
Forum: C++ Nov 5th, 2009
Replies: 3
Views: 214
Posted By daviddoria
I don't understand why you would want to remove stl features? They make things MUCH easier...
Forum: C++ Nov 5th, 2009
Replies: 4
Views: 244
Posted By daviddoria
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...
Forum: C++ Nov 5th, 2009
Replies: 3
Views: 124
Posted By daviddoria
First of all, you should #include <iostream> instead of #include <iostream.h>. This is the "new" c++ way to do it.

Second, you have to #include <cstring> to use strcpy.

Third, you have not...
Forum: C++ Nov 5th, 2009
Replies: 2
Views: 172
Posted By daviddoria
I don't understand the problem...

int NumberOfPositiveRoots(root1, root2)
{
int counter = 0;
if (root1 >= 0)
{
counter++;
}
if (root2 >= 0)
Forum: C++ Nov 5th, 2009
Replies: 6
Solved: Triangle.
Views: 262
Posted By daviddoria
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.
Forum: C++ Oct 24th, 2009
Replies: 5
Views: 167
Posted By daviddoria
Please explain exactly what you need. What operating system are you using?
Forum: C++ Oct 17th, 2009
Replies: 3
Views: 287
Posted By daviddoria
I had to instantiate the constructor by adding this to the instances.inc file:

template Graph<int,int,int>::Graph(int, int, void (*)(char *));


Does anyone understand why / know if the...
Forum: C++ Oct 16th, 2009
Replies: 3
Views: 287
Posted By daviddoria
With this code:
http://www.rpi.edu/~doriad/Daniweb/maxflow/
If I run

g++ Example.cpp graph.cpp


with g++ 3.3, everything works fine. However if I run the same command with g++ 4.4, I get...
Forum: C++ Oct 12th, 2009
Replies: 11
Views: 409
Posted By daviddoria
Interesting - can anyone else confirm?
I am using:
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)
Forum: C++ Oct 12th, 2009
Replies: 4
Views: 222
Posted By daviddoria
Hm I tried that - didn't seem to work. Here is a super simplified version that produces the same error:

http://www.rpi.edu/~doriad/Daniweb/octree/

I still think the problem is simply that they...
Forum: C++ Oct 12th, 2009
Replies: 11
Views: 409
Posted By daviddoria
I'm still getting the same error. Can someone try these files:
http://www.rpi.edu/~doriad/Daniweb/maxflow/

with

g++ Example.cpp graph.cpp
Forum: C++ Oct 12th, 2009
Replies: 11
Views: 409
Posted By daviddoria
I dont think so ...
The constructor is actually:

Graph(int node_num_max, int edge_num_max, void (*err_function)(char *) = NULL);


which is an optional parameter, no? Hence it should be fine...
Forum: C++ Oct 12th, 2009
Replies: 11
Views: 409
Posted By daviddoria
I am doing that:

[doriad@davedesktop test]$ g++ Example.cpp graph.cpp
/tmp/ccHbyqCi.o: In function `main':
Example.cpp:(.text+0x38): undefined reference to `Graph<int, int, int>::Graph(int, int,...
Forum: C++ Oct 12th, 2009
Replies: 4
Views: 222
Posted By daviddoria
Any ideas?
Forum: C++ Oct 12th, 2009
Replies: 11
Views: 409
Posted By daviddoria
Does any one have any clues for me?

Dave
Forum: C++ Oct 9th, 2009
Replies: 4
Views: 222
Posted By daviddoria
I am looking at some open source code and I am a bit confused. There is an Allocator class:

class Allocator{


Then in another class, they have:

class Octree{
public:
static...
Forum: C++ Oct 9th, 2009
Replies: 11
Views: 409
Posted By daviddoria
Here is a simplified version that produces the error:

graph.h

#include <string.h>


template <typename captype, typename tcaptype, typename flowtype> class Graph

{
Forum: C++ Oct 8th, 2009
Replies: 11
Views: 409
Posted By daviddoria
I am trying to compile some code (Example.cpp from here: http://www.rpi.edu/~doriad/Daniweb/maxflow/). I am getting


Example.cpp:(.text+0x38): undefined reference to `Graph<int, int,...
Forum: C++ Sep 20th, 2009
Replies: 6
Views: 622
Posted By daviddoria
Please show us the code that you've come up with so far and we can help guide you.
Forum: C++ Sep 18th, 2009
Replies: 8
Views: 366
Posted By daviddoria
The thing is, I didn't change anything except the debugger and all is well, so I don't think the this pointer could be invalid and it work now?

I have to use the this pointer because of this:...
Forum: C++ Sep 18th, 2009
Replies: 8
Views: 366
Posted By daviddoria
Here is the next line:

std::set<unsigned int>::iterator it;
it = this->SubmeshVertexSet.find(MeshOriginIndex);


SubmeshVertexSet is a member variable:

private:
std::set<unsigned int>...
Forum: C++ Sep 17th, 2009
Replies: 8
Views: 366
Posted By daviddoria
I guess it was a gdb bug? I compiled the latest svn and it gets past that line now with no problems.
Forum: C++ Sep 17th, 2009
Replies: 8
Views: 366
Posted By daviddoria
Unfortunately this is embedded way way way in a huge project. I was trying to see if anyone could offer an "of course I can't be sure, but you could try XYZ".

Dave
Forum: C++ Sep 17th, 2009
Replies: 3
Views: 315
Posted By daviddoria
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?
Forum: C++ Sep 17th, 2009
Replies: 8
Views: 366
Posted By daviddoria
When debugging my code, I put a break point at this line:

std::set<unsigned int>::iterator it;


When I step over that line, I get "Debugger reported the following error: cannot access memory...
Forum: C++ Sep 17th, 2009
Replies: 3
Views: 581
Posted By daviddoria
If that line is remove then there is no warning.

I guess my complaint was just that I thought the warning should say "the function returns before reaching this point" rather than "we have reached...
Forum: C++ Sep 17th, 2009
Replies: 3
Views: 581
Posted By daviddoria
I have a function like this:


bool MyFunction(dist)
{
if(dist < 1.2)
{
std::cout << "Passed test!" << std::endl;
return true;
}
Forum: C++ Sep 16th, 2009
Replies: 4
Views: 433
Posted By daviddoria
I don't see any code there that is adding numbers? Just input and output... Also, please use code tags.
Showing results 1 to 40 of 555

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC