I have some Objective-C++ code that I'm trying to get events out of an Objective-C object to call a method within a C++ object. I'm very new to Objective-C, so I may be doing this all wrong.
Example:
@interface KnobClass {
}
-(void)Event;
@end
class DoorClass {
public:
KnobClass * knob;
void start() { knob = [[KnobClass a...
I am fooling around with C++ and const references and am confused why this code works:
#include <iostream>
class A {
public:
A() : a_(50) {}
const int& getA() const { return a_; }
private:
const int a_;
};
int main(int argc, char* argv[])
{
A* a = new A();
const int& var = a->getA();
std::cout << var << std::en...
I'm trying to compile this C++ program which utilizes the GLUT32 libraries.
Right now I'm getting the following errors:
Error 1 error LNK2001: unresolved
external symbol
_gluPerspective@32 Camera.obj soundCube
Error 2 error LNK2001: unresolved
external symbol
_gluLookAt@72 Camera.obj soundCube Error 3 error LNK2...
I find the update operation on set tedious since there's no such an API on cplusplus. So what I currently do is sth like this:
//find element in set by iterator
Element copy = *iterator;
... // update member value on copy, varies
Set.erase(iterator);
Set.insert(copy);
Basically the iterator return by Set is a const_iterator and you ca...
Hello:
I'm getting some odd behavior in one of my class members and it is truly throwing me for a loop but I'm certainly not seeing the issue (long week!)
void MyFakeStringClass::readStream( iostream& nInputStream )
{
// Hold the string size
UINT32 size = 0;
// Read the size from the stream
nInputStream.read( reinterpr...
When I compile a program using just
gcc code.c
There are no messages, and an output file is generated successfully. The outputted file works. However, when I try to the same cygwin installation's gcc compiler in an IDE (I've tried Netbeans and Dev-C++), I get the following errors
main.cpp:27: error: `exit' undeclared (first use this ...
In C its optional. In C++ one "MUST" declare a function before its used/defined. Why is it so? Whats the need? We don't do that in C# or Java.
Funny thing is while we are defining a function. The definition itself has a declaration even then, we need to declare. God knows why?
...
This question may be a duplicate, but I can't find a good answer. Short and simple, what requires me to declare
using namespace std;
in C++ programs?
...
Hi,
I am asking one basic question about the initialization. My understanding is that the int will be initialized to 0 automatically. However, it's not. The code below print random value. Can anybody tell me the rule of initialization? Under what condition, the variable will be initialized automatically?
int main () {
int a[10];
int i...
Problem with operator[] in c++, i have some class:
197 class Permutation{
198 private:
199 unsigned int* array;
200 unsigned int size;
201
202 void fill(){
203 for(unsigned int i=0;i<size;i++)
204 array[i]=i;
205 ...
What is better adjacency lists or adjacency matrix for graph problems in c++?
And what are the advantages and disadvantages of each?
EDIT:can anyone provide a link with a clean code for say Breadth first search in linked lists format ??
...
My renderer used to render geometry with the old fixed function stuff using glBegin/glEnd. After switching it to use vertex arrays via glVertexPointer et. al., my Cg shaders stopped showing up. If i just do a regular texture binding, it works fine, so the array data is solid. Also if I use the old glBegin/glEnd system, the Cg shaders wor...
I wrote a class that wraps an iterator and returns transformed values on demand:
// iterator-wrapper.h
template<class Iter, class Val, class Fct>
class IteratorWrapper {
Iter cur_;
const Iter last_;
const Fct fct_;
public:
IteratorWrapper(Iter first, Iter last, const Fct fct)
: cur_(first), last_(last), fct_(fct)
{}
con...
Why typedef can not be used with static? For example, the code below is an error
typedef static int INT2;
What other rules should be follow to use the typedef? What other keywords can not be used with typedef?
Thanks so much!
...
Hi,
I'm trying to create a named constructor for my class Matrix, with an input as a stream from which I can read the values for the initialization.
#include <istream>
// ...
class Matrix
{
public:
Matrix(int);
// some methods
static Matrix *newFromStream(istream&);
private:
int n;
std::valarray< Cell > data;
};
...
i have known that winpcap library enabled a person to obtain advanced information about installed devices...
given all the networking devices found in the computer, how will i know which one of this has an internet connection?!
thanks:)
...
How i can read\export data within a C++ application to Excel files? I was found the xlslib project, but it only compiles with MingW on Windows. My target platform is windows (MVS2008)
...
I'm looking for a way to get two programs to efficiently transmit a large amount of data to each other, which needs to work on Linux and Windows, in C++. The context here is a P2P network program that acts as a node on the network and runs continuously, and other applications (which could be games hence the need for a fast solution) will...
I need to write a program that reads in either from ifstream or cin, depending on parameters passed into the program at runtime.
I was planning on doing the following:
istream in;
if(argv[1] == "cin")
{
in = cin;
}
else
{
ifStream inFile;
inFile.open(argv[1].c_str());
in = inFile;
}
However, istream in...
I am writing some code for handling data. There are a number of groups of processing functions that can be chosen by the user that are then applied to the dataset. I would like to implement all these groups in separate places, but since they all take the same parameters and all do similar things I would like for them to have a common int...