I have a class defined as:
class Obj {
public:
int width, height;
Obj(int w, int h);
}
and I need it to contain a static array like so:
int presc[width][height];
however, I cannot define within the class, so it it possible to create a pointer to a 2D array (and, out of curiosity, 3, 4, and 5D arrays), have that as a member ...
Basically my task is having to sort a bunch of strings of variable length ignoring case. I understand there is a function strcasecmp() that compares cstrings, but doesn't work on strings. Right now I'm using getline() for strings so I can just read in the strings one line at a time. I add these to a vector of strings, then convert to cst...
how its faster than cstring functions? is the similar source available for C?
...
My program has two threads:
Main execution thread that handles user input and queues up database writes
A utility thread that wakes up every second and flushes the writes to the database
Inside the main thread, I occasionally need to make reads on the database. When this happens, performance is not important, but correctness is. (I...
I have a parent class and child class (inherited from parent).
In the child class, I have a member function named function_blah();
I used vector<parent*> A to store 5 parent instances, 3 child instances. So the total number of elements in the vector is 8.
I can easily access to member functions of element A[0] to A[4], which are parent...
Given this sample code:
#include <iostream>
#include <stdexcept>
class my_exception_t : std::exception
{
public:
explicit my_exception_t()
{ }
virtual const char* what() const throw()
{ return "Hello, world!"; }
};
int main()
{
try
{ throw my_exception_t(); }
catch (const std::exception& error)
...
Compiler: Visual C++
OS: Windows 7 Enterprise
For some reason, Window::SetFramerateLimit isn't limiting the frame rate in the app I'm working on, but it works fine for others. The framerate is capped to 60, but mine jumps around at 100-99 and then goes down to 50 sometimes. It actually causes serious issues. For example, if I create man...
I have the code:
unsigned int length = strlen(somestring);
I'm compiling with the warning level on 4, and it's telling me that "conversion from size_t to unsigned int, possible loss of data" when a size_t is a typedef for an unsigned int.
Why!?
Edit:
I just solved my own problem. I'm an XP user, and my compiler was checking for 64 ...
In C++ using delete to free memory obtained with malloc() doesn't necessarily cause a program to blow up.
Do you guys think a warning or perhaps even an assertion failure should be produced if delete is used to free memory obtained using malloc()??
Why do you think that Stroustrup did not had this feature on C++?
...
I intended to create a class which only have static members and static functions. One of the member variable is an array. Would it be possible to initialize it without using constructors? I am having lots of linking errors right now...
Class A{
public:
static char a[128];
static void do_something();
}
How would you initialize a[...
Once I read in a statement that
The language feature that "sealed the
deal" to include references is
operator overloading.
Why are references needed to effectively support operator overloading?? Any good explanation?
...
I am developing visual game level editor in c++.
For this I want reflection(RTTI) mechanism to know class attributes at runtime.
I am currently using PDB files for this.But using PDB I couldn't retrieve actual code line for extra information in commented format which is given for that attribute.
Visual studio uses NCB files for intellige...
#include <iostream>
using namespace std;
int main()
{
cout << "Do you need to encrypt or decrypt?" << endl;
string message;
getline(cin, message);
int letter2number;
for (int place = 1; place < sizeof(message); place++)
{
letter2number = static_cast<int>(message[place]);
cout << letter2number <...
I am curious about how c/c++ compiler analyse lib files ? I mean say I create a library containing some classes, I am using that library in my main program. How does compiler know what class names are there in that library. Of course that information is present in binary format, I want to use that functionality in my program, to be speci...
Hi,
I'm now building a video transforming filter that have to transform video frames in real-time.
One of the key requirements of the filter is to have high performance to minimize the number of dropped frames during the transform.
Another requirement that is of lower priority but also nice to have is to make it cross-platform (both PC...
So I am currently getting a strange stack overflow exception when i try to run this program, which reads numbers from a list in a data/text file and inserts it into a binary search tree. The weird thing is that when the program works when I have a list of 4095 numbers in random order. However when i have a list of 4095 numbers in incr...
My simple command line app:
int _tmain(int argc, _TCHAR* argv[])
{
JavaVM *jvm;
JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = "-Djava.class.path=."; //Path to the java source code
vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
vm_args.nOptions = 1;
vm_args.o...
Why new()/delete() is slower than malloc()/free()?
EDIT:
Thanks for the answers so far. Please kindly point out specifications of standard C++ implementation of new() and delete() if you have them thanks!
...
I dont know if it is asked (I couldn't find any).
I want to iterate on this kind of numbers implemented on array;
int a[10];
int i = 0;
for( ; i < 10; i++ )
a[i] = i+1;
now the array has
"1 2 3 4 5 6 7 8 9 10"
and I want to get "1 2 3 4 5 6 7 8 10 9"
and then "1 2 3 4 5 6 7 9 8 10"
"1 2 3 4 5 6 ...
I'm currently writing a Roman Numeral Converter for the fun of it. The problem works up to the aforementioned character precedence.
Since Roman Numerals are not positional, i.e. III does not symbolize 1*whatever base^2 + 1*whatever base^1 + 1*whatever base^0.
That of course makes it hard when somebody types in XIV and I need to make su...