Is it possible to have a class inheriting from a struct?
More specifically, how can I wrap a C struct with a class, so that I can pass class pointers to methods that requires struct ptr and cast back when I receive the pointer in e.g. callbacks?
(Or even more specifically, the address of the class should be same same address as the str...
Hi,
I am trying to write a software for document management. First I Input the blank invoice. then feeds the other invoices with data. Using SIFT detectors i get what type of a invoice it is.
Then I want to remove the interect of the two images. Basically this will keep only the information and remove the common data on the invoice. I ...
So I'm looking for a SQL wrapper for C++ that completely hides any textual SQL statements. I just can't seem to find any, I'm wondering why all the wrappers out there seem at some point to want you to write a textual SQL statement such as:
SELECT * FROM stock WHERE item = 'Hotdog Buns'
here's MySQL++ for example:
mysqlpp::Query quer...
I'm writing some native C++ code which needs to be called from C# (and I can't replace the C++ native code with C# code).
I found memory corruptions while allocating/deallocating some memory in the native C++ code using malloc/free. Then I used LocalAlloc/LocalFree and HeapAlloc/HeapFree and had the same problems.
The allocations/deall...
If I code this
std::map<int, char> example = { (1,'a'),
(2, 'b'),
(3, 'c') };
then g++ says to me
deducing from brace-enclosed initializer list requires #include <initializer_list>
in C++98 ‘example’ must be initialized by constructor, not by ‘{...}’
and that annoys me ...
Possible Duplicate:
Any reason to overload global new and delete?
In what cases does it make perfect sense to overload operator new?
I heard you do it in a class that is very often allocated using new. Can you give an example?
And are there other cases where you would want to overload operator new?
Update: Thanks for all ...
I have made a class and it compiles with no syntax errors, but I get 6 unresolved external symbols?
THE CLASS:
struct CELL {
private:
static bool haslife;
static int x;
static int y;
public:
static bool has_life()
{
return haslife;
}
static void set_coords(int xcoord, int ycoord)
{
x = xcoord;
...
Hi there!
With Core Text it was possible to get the outline of a CGGlyph by CTFontCreatePathForGlyph(...). Now I'd like to port from Core Text to Cocoa's font engine, so the question is:
Is there a way to get the outline for a NSGlyph?
...
Just a quick question
printf("%d", 99 || 44) prints "1" in C
print 99 || 44 prints "99" in perl
There are two different kinds of evaluation. Does each one have a name?
edit: i'm interested to know how this Perl evaluation is commonly called when compared to C. When you say "C example is X, and perl example is not X, but Y" which w...
Hi, all. I can't undestand why the bellow code need a cast to work. Someone can explain it?
class Base {
};
class Derived : public Base {
};
class Class {
public:
Derived member;
};
...
Derived obj;
Base *ptrObj = &obj; // ok, no cast needed
Derived Class::* ptr = &Class::member; // ok
Base Class::* ptr = &Class::member; // ...
Hi,
I met the share library not found on the head node of a cluster with torch. I have built the library as well as specify the correct path of the library while compiling my own program "absurdity" by g++. So it looks strange to me. Any idea? Thanks and regards!
[tim@user1 release]$ make
...
...
g++ -pipe -W -Wall -fopenmp -ggdb...
I'm wondering what the difference is between using a static const and an enum hack when using template metaprogramming techniques.
EX: (Fibonacci via TMP)
template< int n > struct TMPFib {
static const int val =
TMPFib< n-1 >::val + TMPFib< n-2 >::val;
};
template<> struct TMPFib< 1 > {
static const int val = 1;
};
template<>...
I have written those few line:
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
using namespace std;
template <class T> struct First
{
T num;
First() {}
First(const T &a) : num(a) {}
};
template <typename var> bool criterio(First<var> &primo, First<var> &secondo)
{
return (primo.num < se...
From the documentation of the StringPiece class in Chromium's source code:
// A string-like object that points to a sized piece of memory.
//
// Functions or methods may use const StringPiece& parameters to accept either
// a "const char*" or a "string" value that will be implicitly converted to
// a StringPiece.
//
// Systematic usag...
I have a bunch of C++ classes.
I want each class to have something like:
static int unique_id;
All instances of a same class should have the same unique_id; different classes should have different unique_id's.
The simplest way to do this appears to be threading a singleton through the classes.
However, I don't know what's called w...
Hi,
The following code should be self explanatory. I have two questions regarding the used syntax (which is the syntax that must be used). I'll be forever grateful if you could provide me with answers for these presented questions.
template <typename T>
struct A {
template <typename S>
void f (const A<S> &s);
template <typ...
What is the size of character in C and C++ ? As far as I know the size of char is 1 byte in both C and C++.
In C :
#include <stdio.h>
int main(){
printf("Size of char : %d\n",sizeof(char));
return 0;
}
In C++ :
#include <iostream>
int main(){
std::cout<<"Size of char : "<<sizeof(char)<<"\n";
return 0;
}
No surprises, bot...
And here we are for another question.
After the previous one, i finally completed the kDop system and everything related. (Hierarchycal tree of kDop, etc..)
Everything works fine.
Now i want to draw on screen the collision for debug purpose and to see the result of the work. (To see if the hierarchical choice i've done in a particular...
Hi, I'm trying to create QTextEdit with some text, and in this text I have end of line signs (\n), but it is not accepted in QTextEdit object (whole text is displayed without any breaks). Any reason why? Could anyone help me with this?
Thank you.
...
Hi,
What is better coding practice: if I have to have a try/catch block shall I place everything (every initialization and so on) in this block or just those variables which may throw? Is there any difference between those two constructions?
In example:
Having:
struct A {
A();
int a;
int* b;
};
and later on in .cpp...