Hello, the C++ assignment im working on is to ask the user for a 4 digit number and then the program outputs all the possible vanity letters based on a phone keypad. I am currently stuck on the best way to get the program to work and how to write it. Anyone got any ideas? thanks for the help!
...
This question isn't so much a 'how to solve' question as its a question about why doesn't this work?
In C++ I can define a bunch of variables that I want to use across multiple files in a few ways.
I can do it like this:
int superGlobal;
#include "filethatUsesSuperglobal1.h"
int main()
{
// go.
}
That way ONLY works if "filethatU...
I have to use an API provided by a DLL with a header like this
namespace ALongNameToType {
class ALongNameToType {
static void Foo();
}
}
Is there a way to use ALongNameToType::ALongNameToType::Foo without having to type ALongNameToType::ALongNameToType each time? I tried using using namespace ALongNameToType but go...
Is main() (or Main()) in C, C++, Java or C#, a user-defined function or a built-in function?
...
I'm tasked with reading Apple's property list files within a c++ application. Focusing primarily on the xml-type plist files specified in OS X, which mimic a xml-type implementation.. Apple's implementation of their property list is described here:
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/plis...
When my cpp file uses #include to add some header, does my final program's size gets bigger? Header aren't considered as compilation units, but the content of the header file is added to the actual source file by the preprocessor, so will the size of the output file (either exe or dll) will be affected by this?
Edit: I forgot to mention...
I am trying to find an optimal font for gvim to program in C/C++.
I currently have the following in ~/.gvimrc and I don't like it:
if has("gui_gtk2")
set guifont=MiscFixed\ 11
else
set guifont=-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1
endif
set columns=80 lines=50
set guioptions-=T "hide toolbar
"Try to load h...
How can I create a macro for getting the library name a class is compiled into? Is there some way of getting this information from make?
Essentially I'd like to do something like:
# define LIBRARY_NAME (get info from make maybe?)
...
# ifdef LIBRARY_NAME
static const char* s_lib_name = STRINGIZE(LIBRARY_NAME);
Thank y...
How to simulate C# typeof-command behavior in C++?
C# example:
public static PluginNodeList GetPlugins (Type type)
{
...
}
Call:
PluginManager.GetPlugins (typeof(IPlugin))
How to implement this using C++? Maybe QT or Boost libraries provide a solution?
What about the case if you want to implement .GetPlugins(...) in a way that i...
Does anyone have any references for building a full Object/Class reflection system in C++ ?
Ive seen some crazy macro / template solutions however ive never found a system which solves everything to a level im comfortable with.
Thanks!
...
So, I'm using a std::map as an associative array. The map is declared as such:
std::map<int, CustomClass*> CustomContainer;
Later on, I use the CustomContainer object as an associative array, e.g.,
CustomClass* pClass = CustomContainer[ID]
Josuttis states:
If you use a key as the index, for which no element yet exists, a new el...
I have a big troubles with display of UTF-8 data retrieved from the MySQL to the Linux-based C++ application. UTF text is shown as question marks.
The application uses the MySQL C API. So I passed the UTF-8 option after mysql_init() and before mysql_real_connect():
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, 'utf8');
and
mysql_op...
Why is the output of the following code equals to 0 or serven?
cout << 7/9*9; //output 0 (zero) why?
float nine = 9;
float seven = 7;
float i = seven/nine*nine;
cout << i //output 7 Why?
Thanks for the help.
...
I know that you have to do it like this:
int * p;
p = new int[10];
//use array
delete [] p;
Now my question is: Since it's not explicitly stated, how is it possible that the correct amount of memory is freed? Do the OS keep track of the allocated memory and its starting address?
...
Hey all,
I have been trying to build the logstalgia project (http://code.google.com/p/logstalgia/) on my Mac (10.5). Rather than having to link it to the system libraries correctly, I have built and added all of the dependencies to the project. I am new at this, but I do think I have done this correctly, mostly because I have had two o...
I'm creating a logger with the following sections:
// #define LOG(x) // for release mode
#define LOG(x) log(x)
log(const string& str);
log(const ostream& str);
With the idea to do:
LOG("Test");
LOG(string("Testing") + " 123");
stringstream s;
LOG(s << "Testing" << 1 << "two" << 3);
This all works as intended, but when I do:
LOG(s...
Here is an abstract of my code. I'm trying to use glutSpecialFunc to tell glut to use my KeyPress function
class Car : public WorldObject
{
public:
void KeyPress(int key, int x, int y)
{
}
Car()
{
glutSpecialFunc(&Car::KeyPress); // C2664 error
}
}
The error message I get is:
Error 1 error C2664: 'glutSpecialFunc' : cannot ...
Can anyone suggest books or material Unit Tests? Some people consider codes without unit tests as legacy codes. Nowadays, Test Driven Development is the approach for managing big software projects with ease. I like C++ a lot, I learnt it on my own without any formal education. I never looked into Unit Test before, so feel left out. I thi...
If I understand slicing correctly I don't think this could happen with pointers or smart pointers. For example, if you had:
class A
{
int something;
};
class B : public A
{
int stuff;
int morestuff;
};
int main()
{
std::shared_ptr<B> b(new B());
std::shared_ptr<A> a;
a = b;
}
My understanding is that the block of memory ...
I've been attempting to use the C++ stringstream class to do some relatively simple string manipulations, but I'm having a problem with the get() method. For some reason whenever I extract the output character by character it appends a second copy of the final letter.
#include <iostream>
#include <sstream>
#include <string>
using namesp...