We found something similar to the following (don't ask ...):
namespace N {
struct A { struct B; };
}
struct A { struct B; };
using namespace N;
struct ::A::B {}; // <- point of interest
Interestingly, this compiles fine with VS2005, icc 11.1 and Comeau (online), but fails with GCC:
global qualification of class name is inva...
Hello everyone,
i want to get the intellisense in GTkmm application, similarly as we get in dot net under windows. However this time i am using Linux, C++, Gtkmm and Geany as my editor. Please guide how to get the intellisense. Moreover, if any kind of editor supports the property of intellisense, please mention that also.
Thanks and R...
I'm parsing a file and trying to decode coordinates to the right unit.
What happens is that this code is evaluated to 0. If I type it into gdb the result is correct.
int pLat = (int)(
(argv[6].data() == "plus" ? 1 : -1)
* ( atoi(argv[7].data())
+ atoi(argv[8].data()) / 60.
+ atoi(argv[9]...
I have the following C++ code:
typedef int* IntPtr;
const int* cip = new int;
const IntPtr ctip4 = cip;
I compile this with Visual Studio 2008 and get the following error:
error C2440: 'initializing' : cannot convert from 'const int *' to 'const IntPtr'
Clearly my understanding of typedefs is not what is should be.
The reason I...
int, char and bool usually have different sizes. Where int>char>bool, I suppose.
But does the RAM even support this?
How is it built up?
Can it take advantage of bool being only 1 byte and store it in a small "register"?
...
I would like to define a class that accept the pointer to it's parent class as an Argument, but would it be possible to somehow pass it without needing to pass it directly such as:
class Child
{
public:
Child(Parent* hiddenArg);
};
class Parent
{
public:
Child myChild;
};
I know this is weird, but I am making my own Signal/Slot...
My use case:
map<string, Car> cars;
bool exists(const string& name) {
// somehow I should find whether my MAP has a car
// with the name provided
return false;
}
Could you please suggest the best and the most elegant way to do it in C++? Thanks.
...
Hi all,
I have a method
void foo(list<shared_ptr<Base>>& myList);
Which I'm trying to call with a two different types of lists, one of DerivedClass1 and one of DerivedClass2
list<shared_ptr<DerivedClass1>> myList1;
foo(myList1);
list<shared_ptr<DerivedClass2>> myList2;
foo(myList2);
However this obviously generates a compiler ...
I make this program in C++ using Code::Blocks on Ubuntu. I need to turn it into a Windows executable binary (.exe file), but I don't know how to do this. Is it possible?
...
Hello.
I have two machines I'm testing my code on, one works fine, the other I'm having some problems and I don't know why it is.
I'm using an object (C++) for the networking part of my project. On the server side, I do this: (error checking removed for clarity)
res = getaddrinfo(NULL, port, &hints, &server)) < 0
for(p=ser...
The described setup with 2nd monitor to left of primary causes WM_NCHITTEST to send negative values which is apparently not supported according to this post.
I have a custom control written in win32 that is like a Group control. It has a small clickable area. No MOUSE events are coming to my control when the window containing the cust...
I'm a one man show developing a C++ Windows application for a customer. Over the past several months we've been running to the same problems with missing DLL dependencies on customer machines. Despite my best efforts something keeps going wrong and we get angry emails back. My boss and my boss's boss are angry with me and the customer...
I wanna Write data into .txt file created by CFileDialog, in C++.
The problem I am facing is that below codes doesn't work, although there is no build error. The .txt file created by CFileDialog can not be found for some reason. What's wrong the code?
what's the efficient way to Write data into .txt file created by CFileDialog, in C++?...
How would you unit test do_int_to_string_conversion?
#include <string>
#include <iostream>
void do_int_to_string_conversion(int i, std::string& s) {
switch(i) {
case 1:
s="1";
break;
case 2:
s="2";
break;
default:
s ="Nix";
}
}
int main(int argc, char** argv){
std::string...
Is it possible to convert floats from big to little endian? I have a value from a PowerPC(big endian)platform that I am send via TCP to a Windows process (little endian). This value is a float, but when I "memcpy" the value into a win32 float type and then call _byteswap_ulongon that value, I always get 0.0000?
What am I doing wrong...
g++ allows this construction of an istream_iterator from an ifstream instance:
std::ifstream ifstr("test.txt");
std::istream_iterator<std::string> iter1(ifstr);
...but it doesn't allow the same construction with an unnamed temporary:
std::istream_iterator<std::string> iter2(std::ifstream("test.txt"));
This gives:
error: no mat...
What important points about Structured Exceptions should every C++ developer know?
...
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
struct productJewelry
{
string name;
double amount;
int itemCode;
double size;
string group;
};
int main()
{
// declare variables
ifstream inFile;
int count=0;
int x=0;
productJewel...
Every stl container take an allocator as a parameter:
template < class T, class Allocator = allocator<T> > class vector;
If you write your own class It is possible to use your own allocator.
But is it possible to write your own allocator without using templates?
For example, writing this function is not easy if you are not allowed to...
How are the below valid and invalid as shown and what do they mean. When would such a situation arise to write this piece of code.
++x = 5; // legal
--x = 5; // legal
x++ = 5; // illegal
x-- = 5; // illegal
...