c++

how to mod age of empires?

i want to make a game mod for age or empires. i want to change units, buildings, etc pictures. i would also like to change/add new units/buildings/etc and how the game works. sorry this does not explain more.. i don't know what else to add. Btw aoe 1 or 2. ...

Is repeatedly calling size() on a container (during loop) bad?

For efficiency reasons, I always avoid writing loops like this: for(std::size_t i = 0; i < vec.size(); ++i) { ... } where vec is an STL container. Instead, I either do const std::size_t vec_size = vec.size(); for(std::size_t i = 0; i < vec_size; ++i) { ... } or use the container iterators. But how bad is the first solution really...

Coverting Letters to Numbers in a Telephone Number in C++

I have been staring at this all day and I am having a difficult time with this code. I need this program to convert a string of letters, such as Call Cash, into a 7 digit telephone number. I get either one of two outcomes. Either the program does not output any numbers at all or it gets stuck in an infinite loop. Any assistance would be ...

Why does std::basic_ios overload the unary logical negation operator?

The C++ IO streams' base class std::basic_ios defines operator void*() to return !fail() and operator!() to return fail(). That makes me wonder why we need the operator!() at all. Certainly, !is would also work by implicitly calling operator void*() and negating its result. Am I missing something here or is it purely for historical rea...

How can I configure Visual Studio 2010 to build ANTLR grammars for C++ projects?

The .rules files provided with the distribution aren't recognized by VS2010, and I'd really like to avoid having to write a whole MSBuild task and all that for what should be a simple tool. Currently I've been using the pre-build event and making the commandline manually... but that kind of sucks when there's more than one grammar to wo...

about turbo c working under windows 7

i am using windows 7 64 bit laptop.i installed turbo c and write programs using dosbox, but i can't run the program.... when run is selected it show some message like not an :exe plz give solution to this problem ...

Where to delete an object created by factory?

If I have a factory, that creates an object and returns a pointer to it, what will be a better way to delete it: By delete call in the "user" code, or by a new DestructObject function which I should have together with the factory? ...

How can I change console font?

I have a problem with output Unicode in Windows XP console. (Microsoft Windows XP [Version 5.1.2600]) First code is that(from http://blogs.msdn.com/b/michkap/archive/2008/03/18/8306597.aspx) #include #include #include int main(void) { _setmode(_fileno(stdout), _O_U16TEXT); wprintf(L"\x043a\x043e\x0448\x043a\x0430 \x65e5\x67...

randomize functions

void main() { randomize(); char city[][10]={"DEL","CHN","KOL","BOM","BNG"}; int i,fly; for(i=0;i<3;i++) { fly=random(2)+1; cout<<city[fly]<<":"; } } What is the output of the following code snippet? ...

qt signals/slots in a plugin

I have an app with such structure: all the datatypes (class INode) are stored in plugins (DLLs). Some of the datatypes can be drawn (if they're IDrawable). To load an object of, e.g. class PointCloudNode: public INode I have a special input plugin (DLL) which is called class PointCloudParser: public IIOPlugin and IIOPlugin is a thread ...

Problem debugging C++ with an Eclipse based IDE

Hi all, This is a weird question in that I'm not sure where to start looking. First of all, I haven't done any C++ programming for the last 10 years so it could be me thats forgotten a few things. Secondly, the IDE I'm using is Eclipse based (which I've never used) and customized for Samsung bada based mobile development (it kicks off ...

Visibility modes in Classes

We know that private members are not inherited whenever we inherit a base class to get a derived class, but is it possible for derived class member functions to access the private members of the base class? ...

Forward-declaring library names

Hi all, An excerpt from "Exceptional C++": "In the old days, you could just replace "#include " with "class ostream;" in this situation, because ostream used to be a class and it wasn't in namespace std. Alas, no more. Writing "class ostream;" is illegal for two reasons: ostream is now in namespace std, and programmers aren't allowed ...

question about malloc function

i am new in c++and can anybody give me a few example how use malloc in c++ code? ...

Static const initialization iPhone/Release

I have a cross platform library that has strange problem only on iPhone and only under release. // .h class cColor { public: static const cColor Red; static const cColor Green; static const cColor Blue; u8 r; u8 g; u8 b; u8 a; inline cColor(...) : ... { } }; // .cpp const cColor cColor::Red(0xFF, 0x00, 0x00);...

circular class member pointer ?

I am not sure if I can describe the problem, but I will try my best. Here is the situation: If I can want a class1 has a pointer as a member variable pointing to another class, class2. Meanwhile, I want class2 also has a pointer as a member variable pointing to class1. Is that possible? class Class1 { private: Class2* classptr; ...

Convert a single character to a string?

Simple question (in C++): How do I convert a character into a string. So for example I have a string str = "abc"; And I want to extract the first letter, but I want it to be a string as opposed to a character. I tried string firstLetter = str[0] + ""; and string firstLetter = & str[0]; Neither works. Ideas? ...

Always creating instance of class?

I have a class that has only one function "Print()" and two properties "age, sex". And i am trying to understand when is object creating on memory? i can always access to object's props and functions even i didn't call it's constructor function. Isn't there any rule for the creating object from the class? In C# this won't create obj...

how to place .o files into a separate directory, with Makefile rule

I have the following Makefile rules: DIR = src SOURCES = $(shell find $(DIR) -name "*.cpp") OBJS := $(SOURCES:.cpp=.o) With this definition all my .o files are located in the same directories (and sub-directories) as their .cpp counterparts. Such allocation principle turns the project directory into a mess very soon (with 50+ files). ...

Call-stack for exceptions in C++

Today, in my C++ multi-platform code, I have a try-catch around every function. In every catch block I add the current function's name to the exception and throw it again, so that in the upmost catch block (where I finally print the exception's details) I have the complete call stack, which helps me to trace the exception's cause. Is it...