Why is the following code not compiling and how would it be possible to use the function from the base class?
template<typename K> struct Base
{
K foo() { return (K)0; }
};
template<typename K> struct Extension
: public Base<K>
{
K foo(int a) { return (K)a; }
};
int main()
{
Extension<float> e;
e.foo();
return 0;
}...
I have been looking at this game called Minecraft and was intrigued by how it can dynamically generate random maps that look and feel right. What types of algorithms are used to generate terrains based on cubes like this?
Thanks
...
Hello,
I'm trying to implement a generic hierarchical tree for C++ Linux project.
I haven't been able to find any standard library tree containers, though.
Do any exist?
Thanks in advance,
Tim
...
My game draws a series of cubes from a VBO, and just translates to the cube's position each time:
...
SetCameraMatrix();
SetFrustum();
//start vbo rendering
glEnableClientState(GL_VERTEX_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 1);
glVertexPointer(3, GL_FLOAT, 0, 0);
glColor3f(1,0.5,0);
for(int i = 0...
Basically, I want to know if something like the below is possible? If this isn't possible is there any way to fake it?
#include <iostream>
using namespace std;
template<typename Functor>
void foo(Functor func)
{
auto test = [](Functor f){ int i = 5; f(); };
test(func);
}
int main()
{
foo([](){ cout << i << endl;});
}
...
I am trying to create a shared library on Windows. I am able to create this shared library on linux but on windows I get linker errors. I am using the MinGW G++ 4.5 compiler. I will first present the source code to the example on linux , and then present the file which I tried to change on windows.
/home/nxd/Progs/C++/shared-lib>cat lib...
hi,
i've faced an unhandled exception of "General Protection Exception". while the program runs but there is no output.
i wanted to know what are general efforts i can do to debug such an Exception?
thanks
...
Possible Duplicate:
Is there any danger in calling free() or delete instead of delete[]?
I was reading this question:
http://stackoverflow.com/questions/184537/in-what-cases-do-i-use-malloc-vs-new/
Someone raised that one reason to use malloc was if you were going to use free.
I was wondering: Is it valid to mix a free call ...
I wrote my first ever C++ template code on expandable array and I am getting a segmentation fault! After an hour of debugging I have realized that I need help. Something is wrong with the constructor or the destructor I think but not sure.
The code is on pastie ready to be compiled.
http://pastie.org/1150617
/* Expandable array in C++ ...
From this screenshot you can see a lot of space inside the rows:
I've used these functions to get resizing:
resizeRowsToContents();
resizeColumnsToContents();
How can I get a better fit for cells/rows sizes?
...
I'm writing a program in python which should be able to pass "callables" which are registered in a C++ class.
So far I've written the following code:
C++:
class MyClass
{
...
public:
register_callback(boost::function<void (int)> fun);
};
Python/C API:
class_<MyClass, boost::shared_ptr<MyClass>, boost::noncopyable>("MyClass", no_...
I have a directory (DIR_A) to dump from Server A to Server B which is
expected to take a few weeks. DIR_A has the normal tree
structure i.e. a directory could have subfolders or files, etc
Aim:
As DIR_A is being dumped to server B, I will have to
go through DIR_A and search for certain files within it (do not know the
exact name of ...
This is kinda a general question, looking for as much info as possible. I have code which generates this error (the define is DB_E_ERRORSOCCURRED), and I'm looking for the best methods to debug it (eg: figure out what the particular errors were). I'm aware that there are some other SO questions related this this error (eg: here, here, he...
Hi,
I do not see the reason of the leak below.
#include <iostream>
#include <cstdlib>
int fail(const std::string str)
{
std::cerr<< str << std::endl;
exit(1);
}
const std::string usage()
{
std::string a = "a";
return a;
}
int main()
{
fail(usage());
return 0;
}
Valgrind says:
==7238== 14 bytes in 1 bloc...
Hi,
I'm writing an application in c++/MFC and there's a need to create good-quality charts (bar charts, line graphs, maybe even some custom graphics...). As an additional feature, I need to be able to export my graphs in MS Office Graph/Drawing binary file format (so that people can see them in Excel, bitmaps and metafiles just don't c...
I'm trying to achieve tail-like functionality in my Visual Studio 2008 C++ application. (i.e. show in real-time the changes to a file not owned by my process.)
/// name of the file to tail
std::string file_name_;
/// position of the last-known end of the file
std::ios::streampos file_end_;
// start by getting the position of the end o...
This is a sequel to a related post which asked the eternal question:
Can I have polymorphic containers with value semantics in C++?
The question was asked slightly incorrectly. It should have been more like:
Can I have STL containers of a base type stored by-value in which the elements exhibit polymorphic behavior?
If you ar...
How do you solve created by including a header file with the same name as another header file already indirectly included as a result of another include?
For instance:
// src/blah/a.hpp
#ifndef A_HPP
#define A_HPP
namspace blah
{
class A
{
}
}
#endif
// src/blah/b.hpp
#ifndef B_HPP
#define B_HPP
#includes "a.hpp"
namspace blah
{...
I don't have very much information to work with here, yet. Our app sends an HTTP query to our server, and in all the cases we've used until now it has worked fine. But for one client, whose network goes through a proxy, their logs indicate that the request goes out successfully, but no reply ever returns, and our web server shows nothi...
I am writing a piece of software that consists of a kernel mode driver and a user mode Windows service. The kernel driver needs to notify the service of different events and information, which the service will then process.
My question is this: What is the best way to set up this communication? I know it is possible to get a message ...