daviddoria 334 Posting Virtuoso Featured Poster

With normal folders, you can right click them and say "Remove from favorite folders, as per here: http://office.microsoft.com/en-us/outlook/HA011176721033.aspx

However, Calendar and Contacts don't have that option. How would one remove them?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Interesting - can anyone else confirm?
I am using:
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)

daviddoria 334 Posting Virtuoso Featured Poster

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 tried to re-use a name? Is this the case?

daviddoria 334 Posting Virtuoso Featured Poster

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
daviddoria 334 Posting Virtuoso Featured Poster

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 to call it with only 2 ints?

daviddoria 334 Posting Virtuoso Featured Poster

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, void (*)(char*))'
collect2: ld returned 1 exit status

Can anyone confirm this behavior?

daviddoria 334 Posting Virtuoso Featured Poster

Any ideas?

daviddoria 334 Posting Virtuoso Featured Poster

Does any one have any clues for me?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Ah great - I never knew about that!

daviddoria 334 Posting Virtuoso Featured Poster

Great - I guess the problem was mostly with what was contained inside the content-wrap. I didn't end up "clearing" any of the div's, but it seems to be working fine.

Thanks!

daviddoria 334 Posting Virtuoso Featured Poster

perfect - thanks!

daviddoria 334 Posting Virtuoso Featured Poster

I agree about the layout. However if I let the page expand to the screen width then the images specified in pixels will look too big/small unless the resolution is the same as my design resolution, right?

daviddoria 334 Posting Virtuoso Featured Poster

Is there anyway to get images to be the "correct" size - i.e. fit the width of the text?

This is what currently happens:
http://engineeringnotes.net/personal/pictures.shtml

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I see, thanks. However, I have most of the code in a header.shtml file so I can do this:

<div id="wrap">
<!--#include file="header.shtml" -->
    <div id="main">
      Home page
   </div> <!--end main-->

</div> <!--end content wrap from header.shtml-->

So that I can use the same page layout and just server side include different text for each "page" of the site. So now the header.shtml looks like:

<div id="content-wrap">
    <div id="sidebar">
      <h1>Some stuff</h1>
  
    </div> <!--end sidebar-->

You'll note that there is no </div> ending the content-wrap because that appears in the main files (index.shtml for example) AFTER the main-div, as you suggested. This seems a BIT goofy - is this a standard thing to do?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I'm still very new to css, so I'm sure this is just some really silly thing:
http://engineeringnotes.net/personal/

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

daviddoria 334 Posting Virtuoso Featured Poster

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 that they can all be in the same directory?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

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 Allocator<OctNode> Allocator;

When trying to compile, I am getting:

error: declaration of 'Allocator<OctNode<NodeData, Real> > OctNode<NodeData, Real>::Allocator'
error: changes meaning of 'Allocator' from 'class Allocator<OctNode<NodeData, Real> >'

which makes sense, because it is like they are trying to make a variable named Allocator of type Allocator, which doesn't make sense. However, this is a pretty well known project so surely it compiles for most people - I am wondering if anyone can tell me if I am interpreting this correctly and why it may compile for others and what I can do to fix it?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Here is a simplified version that produces the error:

graph.h

#include <string.h>


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

{

public:


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

};

graph.cpp

#include "graph.h"

#include "instances.inc"



template <typename captype, typename tcaptype, typename flowtype> 

	Graph<captype, tcaptype, flowtype>::Graph(int node_num_max, int edge_num_max, void (*err_function)(char *))

{



}

instances.inc

#include "graph.h"



template class Graph<int,int,int>;

template class Graph<short,int,int>;

template class Graph<float,float,float>;

template class Graph<double,double,double>;

Example.cpp

#include <stdio.h>

#include "graph.h"



int main()

{

	typedef Graph<int,int,int> GraphType;

	GraphType *g = new GraphType(/*estimated # of nodes*/ 2, /*estimated # of edges*/ 1); 



	return 0;

}

Any ideas?

Thanks,
Dave

daviddoria 334 Posting Virtuoso Featured Poster

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, int>::Graph(int, int, void (*)(char*))'

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 to somehow tell gcc/g++ to use this file? Or how else could I get this to work?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Please show us the code that you've come up with so far and we can help guide you.

daviddoria 334 Posting Virtuoso Featured Poster

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:
http://www.daniweb.com/forums/thread223239.html

Apparently it doesn't understand the scope (even though I really thought it should?) without it.

Dave

daviddoria 334 Posting Virtuoso Featured Poster

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

so there should not be a problem with it being null, right? In the worst case the find operation should just fail if the set is empty, right?

And why would it crash on the iterator declaration line rather than the line that is potentially actually causing the problem?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I guess it was a gdb bug? I compiled the latest svn and it gets past that line now with no problems.

daviddoria 334 Posting Virtuoso Featured Poster

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

daviddoria 334 Posting Virtuoso Featured Poster

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?

daviddoria 334 Posting Virtuoso Featured Poster

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 at address 0x10".

I am using KDevelop that ships with Fedora 11.

I've used that line of code many many times, so it doesn't make sense that it wouldn't work now..?

Does anyone have any idea what could be wrong?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

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 the end of a function that is supposed to return something, but it did not return anything".

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I have a function like this:

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

gcc tells me "warning- control reaches end of non-void function". However, the conditional must catch all cases (the else catches everything 'else' (by definition)). So clearly all that will happen is the last endl will never be hit. Is that what it is trying to tell me?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I don't see any code there that is adding numbers? Just input and output... Also, please use code tags.

daviddoria 334 Posting Virtuoso Featured Poster

I found that

typename Point<T>::MyDouble a;

works. Why would this->MyDouble not work?

Dave

daviddoria 334 Posting Virtuoso Featured Poster

Well, one more question actually. If in Point I define:

public:
	typedef double MyDouble;

Then in Point3D I try to do:

template< typename T>
void Point3D<T>::Output3D()
{
	std::cout << "X: " << this->X << std::endl;

[B]//none of these work![/B]
MyDouble a; //doesn't work
	//typename this->MyDouble a; //doesn't work
	//this->MyDouble a; //doesn't work
	//typename MyDouble a; //doesn't work
}

What is the syntax I have to use to access that typedef in the derived class?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

Interesting - thanks! Finally a case where you MUST use the 'this' pointer haha.

All is well now, thanks again all!

David

daviddoria 334 Posting Virtuoso Featured Poster

Interesting... I threw that code into a single header file (copy and pasted what you just posted) and I get the same "error: 'X' was not declared in this scope". I am using g++ from gcc version 4.4.0. Can anyone else confirm this behavior (either working or not)?

Thanks,

David

daviddoria 334 Posting Virtuoso Featured Poster

I don't think so? Here is the current version:

Point3D.h

#ifndef POINT3D_H
#define POINT3D_H

#include "Point.h"

template <typename T>
class Point3D : public Point<T>
{
	
	public:
		Point3D(const T x, const T y, const T z) : Point<T>(x,y,z) {}

		void Output3D();
};

template< typename T>
void Point3D<T>::Output3D()
{
[B]	std::cout << "X: " << X << std::endl; //compiler error on this line[/B]
}

#endif

Point.h

#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 Z;};

	void Output();

};

template< typename T>
void Point<T>::Output()
{ 
	std::cout << "x: " << X << " y: " << Y << " z: " << Z << std::endl;
}

#endif

Test:

#include <iostream>
#include <vector>


#include "Point3D.h"

int main(int argc, char* argv[])
{
	
	Point3D<double> C(1.2,2.3,4.5);
	C.Output();
	C.Output3D();

	return 0;
}
daviddoria 334 Posting Virtuoso Featured Poster

Ah, I see - I declared X,Y,Z in Point3D as well - doh! That actually is an interesting question - so there are now 2 different X,Y,Z that can both be used? this->X from Point3D would clearly access the Point3D version, but then how would you access the Point version of X?

Actually - now that I remove X,Y,Z from Point3D I am getting the error that I was attempting to mimic with this example: "error: 'X' was not declared in this scope.

from Point3D.h...

template< typename T>
void Point3D<T>::Output3D()
{
	std::cout << "X: " << X << std::endl; //the error is on this line

}

Shouldn't X be available from Point since Point3D inherits from Point?

Thanks for the help so far!

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I thought what the Point3D constructor was doing is calling the Point constructor which then set X,Y,Z. Since Point3D inherits from Point, Point3D should also have access to those variables since they are protected, no?

daviddoria 334 Posting Virtuoso Featured Poster

I made 2 classes, Point and Point3D:

Point.h:

#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 Z;};

	void Output();

};

template< typename T>
void Point<T>::Output()
{ 
	std::cout << "x: " << X << " y: " << Y << " z: " << Z << std::endl;
}

#endif

Point3D.h:

#ifndef POINT3D_H
#define POINT3D_H

#include "Point.h"

template <typename T>
class Point3D : public Point<T>
{
	T X,Y,Z;
	public:
		Point3D(const T x, const T y, const T z) : Point<T>(x,y,z) {}

		void Output3D();
};

template< typename T>
void Point3D<T>::Output3D()
{
	std::cout << "3D" << std::endl;
	
	//these both show junk values
	//std::cout << "X: " << this->X << std::endl;
	//std::cout << "X: " << X << std::endl;
	
	//this says "there are no arguments to 'getX' that depend on a template parameter, so a declaration of 'getX' must be available
	double x = getX();
	std::cout << "X: " << x << std::endl;
}

#endif

Test.cpp

#include <iostream>

#include "Point3D.h"

int main(int argc, char* argv[])
{
	
	Point3D<double> C(1.2,2.3,4.5);
	C.Output(); //works fine
	C.Output3D(); //doesn't work

	return 0;
}

The problem is with the Output3D function. It doesn't seem to be able to access the protected variables in Point (they just are garbage values). If I try to use the accessors, there are compiler errors (described with comments in the …

daviddoria 334 Posting Virtuoso Featured Poster

Why are you trying to lock an uninitialized surface? This seems to work fine:

int main( int argc, char** argv )
{
	SDL_Init(SDL_INIT_EVERYTHING);
	SDL_Surface* screen = SDL_SetVideoMode(500,500,32,0);
	
	SDL_LockSurface(screen);
	SDL_UnlockSurface(screen);

	SDL_Flip(screen);

	SDL_Delay(1000);

	SDL_Quit();
	return 0;
}
daviddoria 334 Posting Virtuoso Featured Poster

1) The undefined reference is because you are not linking to SaveData.cpp. Which IDE are you using (Visual studio, etc)?

2) 'retreive' should be spelled 'retrieve'.

3) you seem to still be using the 5th element (element 4), when it is not valid.

4) it seems to work just fine when you change void outputSavedata (int* stats); to void outputSavedata (int stats[4]);

daviddoria 334 Posting Virtuoso Featured Poster

You have to create the array in the scope that you are going to use it! Probably the way to go here is have the retrieve() function accept a pointer to the array it will fill. Also, be careful not to use element 4 of an array[4] - it has 4 elements, 0,1,2,3!

#include <iostream>

void retreiveSavedata (int* stats);
void outputSavedata (int stats[4]);


int main()
{
	int stats[4];	
	retreiveSavedata(stats);
	outputSavedata(stats);
	return 0;
}

void outputSavedata (int stats[4])
{

	std::cout<< "\nStrengh:" << stats[0] << "\n";
	std::cout<< "Defense:" << stats[1] << "\n";
	std::cout<< "Hitpoints:" << stats[2] << "\n";
	std::cout<< "Experience:" << stats[3] << "\n";
	

}


void retreiveSavedata (int* stats)
{

	stats[0] = 0;
	stats[1] = 10;
	stats[2] = 20;
	stats[3] = 30;
	
}
daviddoria 334 Posting Virtuoso Featured Poster

Can you provide the shortest possible compilable example that produces the error ?

daviddoria 334 Posting Virtuoso Featured Poster

You don't seem to have posted the whole code - there are errors on line 75 but you've only posted 35 lines!

daviddoria 334 Posting Virtuoso Featured Poster

Please ask specific questions. Also, provide sample input, expected output, and the current (incorrect output).

daviddoria 334 Posting Virtuoso Featured Poster

Which IDE are you using? (Visual studio, KDevelop, etc) I know in KDevelop the little command window is broken such that it just ignores cin type statements... seems very odd but I always have to open a real terminal window and run the program if my program expects input.

daviddoria 334 Posting Virtuoso Featured Poster

This seems to work fine for me...

#include <iostream>
#include <fstream>

using namespace std;

void skrivtilfil (string placering);
void laesfrafil ();
int main()
{
	int ioro;
	cout << "in or out? ";
	cin >> ioro;
	if (ioro == 1)
	{
		std::cout << "Pressed 1. " << std::endl;
	}
	else if (ioro == 2)
	{
		std::cout << "Pressed 2. " << std::endl;
	}

	return 0;
}
daviddoria 334 Posting Virtuoso Featured Poster

Sorry, we will not just do your assignment for you. We also cannot teach you all of c++ - you're going to have to give it an attempt and we can help when you run into problems.

daviddoria 334 Posting Virtuoso Featured Poster

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 hits one line (declaring an iterator):

typename EdgeIdentifierContainerType::const_iterator it;

I get "cannot acces memory at 0x0". It lets me continue debugging, but every line after that I get the same error.

Does anyone have any guesses at what could be causing this?

Thanks,

Dave

daviddoria 334 Posting Virtuoso Featured Poster

I used the debugger to step through the code and it gets all the way to the end with no errors. Only when I run the program without the debugger does it segfault after everything finished.

daviddoria 334 Posting Virtuoso Featured Poster

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).

int main()
{
 ..... my code here...
	std::cout << "Finished." << std::endl;
	
	return 0;
}

I see "Finished." printed, and then there is a segmentation fault. Is there a common thing that could cause this (i.e. memory not released, etc) that I can look for?

David

daviddoria 334 Posting Virtuoso Featured Poster

Wow, unbelievable! Seems like there should be some better way to catch this, like "this namespace does not exist".

Sorry for the stupid typo - thanks though.

Dave