I'm trying to link to a shared library with a template class, but it is giving me "undefined symbols" errors. I've condensed the problem to about 20 lines of code.
shared.h
template <class Type> class myclass {
Type x;
public:
myclass() { x=0; }
void setx(Type y);
Type getx();
};
shared.cpp
#include "shared.h"
template <cla...
I just finished and passed data structures and I need a good programming project for the summer to keep my skills sharp.
...
I have an application that is based on a message-pump thread-pool archtecture. Whenever there is an action that could block, it is implemented as "callback on complete/trigger evnet" action, so it won't stall the executing thread.
While this techniqiue is appropriate for most cases, there are situations when it becomes very inconvinient...
I've got a pretty strong background in C-style languages. And have worked on several different types of projects. I have just started taking a serious look at Python after reading Programming Collective Intelligence. I understand that Python can solve any problem that C# can, and vice-versa. But I am curious to know from those who us...
std::string str;
std::stringstream strm(str);
I get this error:
Error 11 error C2248:
'std::basic_ios<_Elem,_Traits>::basic_ios'
: cannot access private member
declared in class
'std::basic_ios<_Elem,_Traits>' c:\program
files\microsoft visual studio
9.0\vc\include\sstream 517
If I use istringstream, same happens...
It seems to me that Linux has it easy with /proc/self/exe. But I'd like to know if there is a convenient way to find the current application's directory in C/C++ with cross-platform interfaces. I've seen some projects mucking around with argv[0], but it doesn't seem entirely reliable.
If you ever had to support, say, Mac OS X, which do...
It's pretty easy to use a library in VC++ 2008 if you create a project for it and build it alongside the other projects in your solution, but what if the library has too complex of a build process and must be compiled separately via makefile?
My library is like that, and while I've had no problem compiling it on the command line, I have...
Hey guys,
So I've got an application that starts another application with my DLL injected (with Detours). The entry point is DllMain. I can't do much from DllMain, and certainly cannot loop. So how do I call my DLL monitor functions every x seconds? I read you cannot create a thread from DllMain (at least until it returns) and its true ...
Consider the following set of classes/Interfaces:
class IFish{
public:
virtual void eat() = 0;
}
class IFriendly{
public:
virtual void protect() = 0;
}
class IAggresive{
public:
virtual void attack(Point inDest) = 0;
}
class CDolphin : public IFish, IFriendly{
eat...
protect....
}
class CShark : public IFish, IAggresive{
eat....
...
When my process crashes, how can I print to log a core dump file stack, C++ over windows?
I know that in Unix there is a way to do it using some signal handlers but never did it myself.
How can I do it in windows (prefer not to use ACE)?
Thanks.
...
Hi,
I'm trying to create a program that takes a text file of c++ code and outputs another
file with that code, minus any comments that it contains.
Assuming that rFile and wFile are defined as follows:
ifstream rFile; // File stream object for read only
ofstream wFile; // File stream object for write only
rFile.open("input.txt", ios:...
I need to use system-specific functions, e.g. ftello() (defined in stdio.h as per POSIX standard).
I also need to use standard C++ features, e.g. std::sprintf() (defined in cstdio, as per ISO C++ standard).
AFAIK, including only <cstdio> doesn't guarantee defining non-standard-C++ stuff, so I guess I have to include both.
I've read a lo...
I am developing a program where I find myself doing this like this a lot:
void Model::SetCollideMode( const std::string &m )
{
Body *body;
std::map<std::string, Body* >::iterator iter;
for (iter=this->bodies.begin(); iter!=this->bodies.end(); iter++)
{
body = iter->second;
body->SetCollideMode( m );
}
}
I have sev...
I'm looking for a good setup for learning C++ and eventually Python on Mac OSX. As I'm going use C++ I don't want to use XCode, as (I understand) this is primarily used with Objective-C. I have a small bit of experience in Java and MATLAB programming, and math is probably not going to be my main problem. I was thinking on an approach loo...
C# will not allow to write non-member functions and every method should be part of a class. I was thinking this as a restriction in all CLI languages. But I was wrong and I found that C++/CLI supports non-member functions. When it is compiled, compiler will make the method as member of some unnamed class.
Here is what C++/CLI standard ...
We are developing some stress and strain analysis software at university. Now it's time to move from rectangles and boxes and spheres to some real models. But I still have little idea where to start.
In our software we are going to build mesh and then make calculations, but how do I import solid bodies from CAD/CAE software?
1) How CAD...
Hi all, I was reading litb's question about SFINAE here and I was wondering exactly what his code is declaring. A simpler (without the templates) example is below:
int (&a())[2];
What exactly is that declaring? What is the role of the &? To add to my confusion, if I declare the following instead
int b()[2];
I get an error about dec...
Hi, I am writing a file splitting program, to assist with using large files with iPod notes. I want to use tmpfile() in cstdio but it returns a file* not an fstream object. I know it's not possible in standard C++ but does anyone know any libraries that work well with the standard that have the ability to convert a FILE* to an std::fstre...
I am solving problem 9 on the Project Euler. In my solution I use a "goto" statement to break out of two for loops. The Problem is the following:
A Pythagorean triplet is a set of three natural numbers, a b c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean t...
I'm trying to profile a C++ application, that I did not write, to get a sense for where the major computation points are. I'm not a C++ expert and even less so C++ debugging/profiling expert. I believe I am running into a (common?) problem with dynamic libraries.
I compile link to Google CPU Profiler using (OS X, G++):
env LIBS=-lpro...