why in C++, for objects A,B
//interface, case #1
class A {
B bb;
}
A::A()
{ //constructor
bb = B();
}
//interface, case #2
class A {
B *bb;
}
A::A()
{ //constructor
bb = new B();
}
Why case #2 work but not #1??
Edit: I got it now. But for case #1, if an instance of A is freed, will its bb also be automatically freed? Case #2 yo...
I am extracting images from a MySQL database using the MySQL++ API. I get the images as mysqlpp::sql_mediumblob which is representation of string. Now I want to rotate some pictures using GDI+, but I am not sure how to use this constructor:
Image::Image(IStream*,BOOL) - Creates an Image object based on a stream.
with the image that is...
Are there good open-source projects on P2P file-sharing systems or
distributed file systems written in C/C++ ?
I need a project to start with network-programming.
Can anyone give me any suggestions?
...
Im starting to add d3d10 support to go along with my existing d3d9 graphics backend.
The problem is all the existing code (in several applications...) uses ARGB formatted colours however I couldnt find a format mode that matches for d3d10. Does d3d10 not support ARGB colour formats at all or have I just missed something? If I havnt miss...
Is there a site that provides a great list of common C++ optimization practices?
What I mean by optimization is that you have to modify the source code to be able to run a program faster, not changing the compiler settings.
...
Hello,
Can someone please guide me on how to pass the reference pointer to the dialog class so that it can call DoModal?
e.g.
EditorSvr.cpp -- implementation of the interface class (which is also located in a DLL)
CDialogClass1.cpp -- Dialog class that will receive the pointer from EditorSvr.cpp
I tried to search the whole google bu...
What would you suggest the best tool to profile C/C++ code and determine which parts are taking the most time. Currently, I'm just relying on logs but ofcourse the information is not accurate since unnecessary delays are introduced.
Preferrably, the tool would also be able to detect/suggest areas which could be optimized, if such tool e...
How do you port C++ programs with makefile made from GNU C++ in Linux to Visual C++?
...
Is using .h as a header for a c++ file wrong?
I see it all over the place, especially with code written in the "C style".
I noticed that Emacs always selects C highlighting style for a .h header, but c++ for hpp or hh.
Is it actually "wrong" to label your headers .h or is it just something which annoys me?
EDIT:
There is a good (is...
Can anyone help me ? I'm trying to add the testing facilities from boost library and I'm stuck. Let's suppose that i have a source file like this (the simplest one):
#define BOOST_TEST_MAIN
#include
BOOST_AUTO_TEST_CASE(test) {
BOOST_CHECK(1 + 1 == 2);
}
How is suppose to look the corespondent Jamfile ? Thank you !
...
I would to know if there is a tool in C++ that gives you a report where it displays the following:
The source code of the whole project. Usually one HTML page per source file.
Beside the source code, there are line numbers, for readability purposes of course.
And for each line, at the left of the line number, there is a value displaye...
What is the order in which the destructors and the constructors are called in C++? Using the examples of some Base classes and Derived Classes
...
C++ ISO standard says, that:
"A function defined within a class definition is an inline function."
Are there any compilers that IGNORE this rule?
(please, do not mistake inline with inlineD - my question is if there is a compiler, that wont put there that inline suggestion that it should)
...
My first post so please go easy on me!
I know that there's no real difference between structs and classes in C++, but a lot of people including me use a struct or class to show intent - structs for grouping "plain old data" and classes for encapsulated data that has meaningful operations.
Now, that's fine but at what point do you start...
Hello,
Is there a difference between using const:
Cannot change the datatype but can change the value of a or b
int add(const int a, const int b);
Can change the datatype but cannot change the value of a or b
int add(int const a, int const b);
Cannot change the datatype and cannot change the value of a or b
int add(const int con...
What is the difference between these two file types. I see that my C++ app links against both types during the construction of the executable.
How to build .a files? links, references, and especially examples, are highly appreciated.
...
I trying to use a ".h" file from Windows SDK in a .NET language (maybe C#), but without success. This header exposes some Windows Media player functionality through COM. If I use Win32 C++, I can use it with no problems, so I thought that I could use Managed C++ as a "Bridge" to expose it to C#.
The header file is the subscriptionservic...
A lot of C++ books and tutorials explain how to do this, but I haven't seen one that gives a convincing reason to choose to do this.
I understand very well why function pointers were necessary in C (e.g., when using some POSIX facilities). However, AFAIK you can't send them a member function because of the "this" parameter. But if you'...
C++ ISO standard says: "A function defined within a class definition is an inline function." *
Do you know about any compilers that IGNORE this rule?
Do you know about any compilers that WILL NOT put that 'inline suggestion' there?
(please do not repeat the theory about inlines, I am aware of that - I need a practical answer)
...
We have a VS2005 native C++ application which connects to Exchange
server using CDOEX and CDOEXM to create and modify calendar entries
for multiple user folders. It's a command line utility which must be installed on the same server where the exchange server is installed. What is the correct procedure to use this
utility in a clustered e...