Click here to Skip to main content
15,921,697 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Vector VS. Array BUG Pin
Stephen Hewitt25-Mar-08 20:05
Stephen Hewitt25-Mar-08 20:05 
GeneralMessage Removed Pin
25-Mar-08 20:06
Armond Sarkisian25-Mar-08 20:06 
GeneralRe: Vector VS. Array BUG Pin
Stephen Hewitt25-Mar-08 20:10
Stephen Hewitt25-Mar-08 20:10 
GeneralRe: Vector VS. Array BUG Pin
Steve Echols25-Mar-08 19:58
Steve Echols25-Mar-08 19:58 
GeneralMessage Removed Pin
25-Mar-08 20:04
Armond Sarkisian25-Mar-08 20:04 
GeneralRe: Vector VS. Array BUG Pin
Steve Echols25-Mar-08 20:20
Steve Echols25-Mar-08 20:20 
GeneralRe: Vector VS. Array BUG Pin
Rajasekharan Vengalil25-Mar-08 20:06
Rajasekharan Vengalil25-Mar-08 20:06 
GeneralRe: Vector VS. Array BUG Pin
Stephen Hewitt25-Mar-08 20:09
Stephen Hewitt25-Mar-08 20:09 
There is no bug, you just aren't logging enough! Try this code:
// VanillaConsole.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
 
class Log
{
public:
	Log()
	{
		cout << "Log()" << endl;
	}
 
	Log(const Log &copy_me) 
	{
		cout << "Log(const Log &copy_me)" << endl;
	}
 
	~Log() { cout << "~Log()" << endl; }
};
 
int main()
{
	vector<Log> g_Log(10);

	return 0;
}


The output is:
Log()
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
Log(const Log &copy_me)
~Log()
~Log()
~Log()
~Log()
~Log()
~Log()
~Log()
~Log()
~Log()
~Log()
~Log()


Looks like a reference element is created using the default constructor and the copy constructor is used to construct the actual vector's elements by copying the reference element.

Steve

modified on Thursday, April 3, 2008 12:23 AM

GeneralMessage Removed Pin
25-Mar-08 20:11
Armond Sarkisian25-Mar-08 20:11 
GeneralRe: Vector VS. Array BUG Pin
Stephen Hewitt25-Mar-08 20:16
Stephen Hewitt25-Mar-08 20:16 
GeneralRe: Vector VS. Array BUG Pin
Steve Echols25-Mar-08 20:14
Steve Echols25-Mar-08 20:14 
GeneralRe: Vector VS. Array BUG Pin
Stephen Hewitt25-Mar-08 20:21
Stephen Hewitt25-Mar-08 20:21 
GeneralRe: Vector VS. Array BUG Pin
Steve Echols25-Mar-08 20:31
Steve Echols25-Mar-08 20:31 
GeneralOn Dialog Box Pin
Chandrasekharan P25-Mar-08 18:20
Chandrasekharan P25-Mar-08 18:20 
GeneralRe: On Dialog Box [modified] Pin
rp_suman25-Mar-08 19:29
rp_suman25-Mar-08 19:29 
GeneralRe: On Dialog Box Pin
Chandrasekharan P25-Mar-08 19:56
Chandrasekharan P25-Mar-08 19:56 
AnswerRe: On Dialog Box Pin
Rajkumar R25-Mar-08 19:45
Rajkumar R25-Mar-08 19:45 
GeneralRe: On Dialog Box Pin
Chandrasekharan P25-Mar-08 20:25
Chandrasekharan P25-Mar-08 20:25 
GeneralRe: On Dialog Box [modified] Pin
Rajkumar R25-Mar-08 21:22
Rajkumar R25-Mar-08 21:22 
GeneralRe: On Dialog Box Pin
rp_suman25-Mar-08 19:55
rp_suman25-Mar-08 19:55 
GeneralRe: On Dialog Box Pin
Chandrasekharan P25-Mar-08 20:07
Chandrasekharan P25-Mar-08 20:07 
GeneralRedirection in command line "&lt;" Pin
uusheikh25-Mar-08 17:30
uusheikh25-Mar-08 17:30 
GeneralRe: Redirection in command line "&lt;" Pin
User 58385225-Mar-08 17:59
User 58385225-Mar-08 17:59 
GeneralRe: Redirection in command line "&lt;" Pin
fefe.wyx25-Mar-08 18:21
fefe.wyx25-Mar-08 18:21 
GeneralRe: Redirection in command line "&lt;" Pin
uusheikh25-Mar-08 20:18
uusheikh25-Mar-08 20:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.