I know that memory alloced using new, gets its space in heap, and so we need to delete it before program ends, to avoid memory leak.
Let's look at this program...
Case 1:
char *MyData = new char[20];
_tcscpy(MyData,"Value");
.
.
.
delete[] MyData; MyData = NULL;
Case 2:
char *MyData = new char[20];
MyData = "Value";
.
.
.
delete[] M...
In C++ do you always have initialize a pointer to an object with the new keyword?
Or can you just have this too:
MyClass *myclass;
myclass->DoSomething();
I thought this was a pointer allocated on the stack instead of the heap, but since objects are normally heap allocated, I think my theory is probably faulty??
Please advice.
...
Can i have a class
Class Room{ ~Room(); virtual cost()
=0; }
Class Hotel{ map rooms; /*
*/ };
will my hotel become abstract ?
Can it hold the list of concrete Room objects that are derived from Room ?
...
Hi folks,
First of all thanks for your time reading my question :-)
I have an original image (w': 2124, h': 3204) and the same image scaled (w: 512, h: 768). The ratio for width is 4.14 (rw) and the ratio for height is 4.17 (rh).
I'm trying to know the coordinates (x', y') in the original image when I receive the coordinates in the s...
Hello,
I have to program some financial applications where I have to represent a schedule of flows. The flows can be of 3 types:
fee flow (just a lump payment at some date)
floating rate flow (the flow is dependant of an interest rate to be determined at a later date)
fixed rate flow (the flow is dependant of an interest rate determine...
Hello!
I am currently on a project which has been buggy for a long while, now I suspect, among other things, that there is pointer errors in the code.
The program is written in native C++ using COM and uses out-of-process COM servers.
Can anybody give me some tips as how one would go about finding these errors?
Is there specific th...
Hi All,
I think most would be surprised about the topic again, However I am referring to a book "C++ Common Knowledge: Essential Intermediate Programming" written by "Stephen C. Dewhurst".
In the book, he quotes a particular sentence (in section under Item 5. References Are Aliases, Not Pointers), which is as below
A reference is ...
This is possibly a candidate for a one-line answer. I would like know it anyway..
I am writing a simple circular buffer and for some reasons that are not important for the question I need to implement it using an array of doubles. In fact I have not investiated other ways to do it, but since an array is required anyway I have not spent ...
I understand that wherever possible we shall use forward declarations instead of includes to speed up the compilation.
I have a class Person like this.
#pragma once
#include <string>
class Person
{
public:
Person(std::string name, int age);
std::string GetName(void) const;
int GetAge(void) const;
private:
std::string ...
I had a C# .NET windows application having C# user interface and all the code behind processing is done by calling C++ dll (C++ class library project) which is added as a reference to the C# project.
However recently when I formatted my computer and again tried to run my project which was backed up, in visual studio 2005 it gave the fol...
Have a quick question about what would be the best way to implement iterators in the following:
Say I have a templated base class 'List' and two subclasses "ListImpl1" and "ListImpl2". The basic requirement of the base class is to be iterable i.e. I can do:
for(List<T>::iterator it = list->begin(); it != list->end(); it++){
...
}
...
Hello
The XML contains symbols that the C++ may misinterpret (like the // in http://www.w3.org/2000/10/XMLSchema)
I am wondering if you know about clean ways to include some hard-coded XML into a std::string or a CString, at compile time.
(in deed I'm trying to encode an .xsd file for validating some xml input, because I don't want to...
Hi
I would like to write a piece of code which checks, for each network device (e.g. eth0, lo, master devices) some statistics and configuration data about that device.
I could find the statistics data (and most of the configuration data) in /sys/class/net/..., however, I couldn't find any C/C++ API or any entry in procfs/sysfs listing t...
Hello,
Some days ago, I decided that it would be fun to write a streambuf subclass that would use mmap and read-ahead.
I looked at how my STL (SGI) implemented filebuf and realized that basic_filebuf contains a FILE*. So inheriting from basic_filebuf is out of the question.
So I inherited from basic_streambuf. Then i wanted to bind my ...
Dear all,
I would like to know whether i can get the drive information using the
SP_DEVICE_INTERFACE_DETAIL_DATA's DevicePath
my device path looks like below
"\?\usb#vid_04f2&pid_0111#5&39fe81e&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"
also please tell me in the winapi they say "To determine whether a drive is a USB-type drive, c...
I often see __WIN32, WIN32 or __WIN32__. I assume that this depends on the used preprocessor (either one from visual studio, or gcc etc).
Do I now have to check first for os and then for the used compiler? We are using here G++ 4.4.x, Visual Studio 2008 and Xcode (which I assume is a gcc again) and ATM we are using just __WIN32__, __APP...
I am trying to use Eclipse CDT with Cygwin, but I have problems with the debugger. I have done the following:
- installed Eclipse CDT
- installed Cygwin with gcc, g++ make and gdb
- added c:\cygwin\bin to PATH
- created a new Hello World application in Eclipse
Compiling went well from Eclipse. The first problem was that I had to set the...
I have an application where the entire database is implemented in memory using a stl-map for each table in the database.
Each item in the stl-map is a complex object with references to other items in the other stl-maps.
The application works with a large amount of data, so it uses more than 500 MByte RAM. Clients are able to contact th...
I have a struct viz:
struct NameKey
{
std::string fullName;
std::string probeName;
std::string format;
std::string source;
}
which are held in a QList:
QList<NameKey> keyList;
what I need to do is find an occurence in keyList of a partial match where the search is for a NameKey that only has two ...
Hello,
I am going through the process of trying to figure out how a library of code works. I would like some sort of tool that would analyze the program that I run off of the library and tells me what functions are called in what order by each thread. Does such a tool exist? What google terms would I use to find such a program?
Note: ...