Delete pointer to a structure
one of the cpp files has a structure pointer created with "new" operator. Should that pointer be explicitly deleted? Or is the pointer automatically deleted? ...
one of the cpp files has a structure pointer created with "new" operator. Should that pointer be explicitly deleted? Or is the pointer automatically deleted? ...
When saving something to a text file is there a way to not override whats in the file already? EX. blah.txt this is an example fout << "of saving to a file."; i want the "of saving to a file" to be added on to "this is an example" not to override it. ...
I would assume that this is covered in the C++ Standard, but I've not been able to find it. I am writing some templates that are going to do arithmetic on their non-type integral parameters, and I find I need the equivalent of MAX_INT for the parameter 'x' in a template like template <int x> Foo. Ideally someone could point me to the pa...
Hi All, I have begun writing some code for a library I need. The following code gives me an error class node { public: node() { } node(const node&); ~node() { } luint getID() { return this->ID; } node& operator=(const node&); protected: luint ID; std::vector<node*> neighbors; }; node::node( const node& inNod...
I just recently finished reading Secure Coding in C and C++ by Brian Seacord, who works for CERT. Overall, it's an excellent book and I would recommend it to any programmer who hasn't yet read it. After reading it, it occurs to me that for all the various types of security vulnerabilities (such as exploit code injection, buffer overf...
Does it matter if the function definition is before the int (main) or after the int main? I've seen it both ways and am trying to find the proper way to display the function definition and declaration. ...
Hello, I like to know if there's a open-source, cross-platform library for capturing web-cam data. Any other suggestions are welcome in case such solutions are not available. I am looking for something similar to portaudio if possible but this is not absolutely mandatory. Also open-source & cross-platform projects falling into this cat...
When dealing with multidimensional arrays is it possible to assign two different variable types to the array... For example you have the array int example[i][j] is it possible for i and j to be two completely different variable types such as int and string? ...
Hi all, after working some time in my project, this warning begin to appear: 2>Game.cpp 2>c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(126) : warning C4005: 'APIENTRY' : redefinición de macro 2> c:\users\ferran\directo\gameprojects\dev-libs\glfw\include\glfw.h(72) : vea la definición anterior de 'APIENTRY' 2>c:...
I searched the web and other groups as well as CodeBlocks. When I create a new class, or when it creates a new header file, I would like it to use ".hpp" for C++ header files. How do I tell it to do this? ...
Consider the following simple polymorphism ... class Parent { public: someFunc() { /* implementation A */ }; }; class Child : public Parent { public: someFunc() { /* implementation B */ }; }; int main () { Parent* ptr; ptr = new Parent(); ptr->someFunc(); delete ptr; ptr = new Child(); ptr->someFunc()...
Suppose I have a class like class A { int x; int y; public: getSum1() const { return getx() + y; } getSum2() const { return y + getx(); } getx() const { return x; } } And then I have int main(int argc, char **argv) { A *a = 0; switch(argc) { case 0: a->gets...
simplifying my problem we can consider: template <class T> class Base{ typedef typename std::pair<T, T> pair; }; template <class T> class Inheritor : public Base<T> { pair *p; // mean that we want to use constructor of std::pair. // say: std::pair withou argument list Inheritor<T>::pair *p...
What is the difference between: const double& pi = 3.14; and (no ampersand): const double pi = 3.14; They both seem to have the same L and R values so what is the difference? Thanks. ...
When I have a class that contains pointers as member variables what type of smart pointer should they have if I want don't want to use plain pointers? They do not need to be shared (so no shared_ptr necessary). scoped_ptr won't work since I often need to build the objects outside of the initialization list. Or is it maybe common practic...
Just saw this question relating to a segmentation fault issue in a C++ class and program. My question relates to the class definition. Here it is as it was posted: class A { int x; int y; public: getSum1() const { return getx() + y; } getSum2() const { return y + getx(); } get...
Is it possible to refer to the address value the pointer variable holds. My function is something(int &num); and I need to pass a pointer to it; int* i = new int(1); like &(*(i)); can this be done? im using qt and I don't know why but; *&ui->numberInput->text() gives a QString &ui->numberInput->text() gives a *QString, *ui->numberOutput...
What would be end of source in this case when getting a string input from console? int main() { std::vector<std::string> str; copy (istream_iterator<std::string>(std::cin), istream_iterator<std::string>(), std::back_inserter(str)); } ...
I use Visual C++ (7.1 and 8.0) on huge C++ project. The solution contains thousands of files. Visual Assist helps in jumping to function and class definitions. The problem is that it sometimes becomes too slow. I just can't edit a single letter without delay. Is there some alternative to this environment? I mean something that may read ...
It seems like every library I've ever seen recommended doesn't offer an api as easy as this. MyClass* instance = (MyClass*)SerializationUtility.serialize(someString); Has anyone heard of something this easy for c++? In hava there are a couple of libraries that are so easy to use for converting text into objects and objects into text. ...