Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: In C++ compiler providing the default copy constructor ,then why do we need copy constructor Pin
David Crow20-Sep-16 5:22
David Crow20-Sep-16 5:22 
GeneralRe: In C++ compiler providing the default copy constructor ,then why do we need copy constructor Pin
Krishnakumartg20-Sep-16 22:13
Krishnakumartg20-Sep-16 22:13 
AnswerRe: In C++ compiler providing the default copy constructor ,then why do we need copy constructor Pin
jeron120-Sep-16 5:23
jeron120-Sep-16 5:23 
AnswerRe: In C++ compiler providing the default copy constructor ,then why do we need copy constructor Pin
Saravanan Sundaresan24-Sep-16 19:53
professionalSaravanan Sundaresan24-Sep-16 19:53 
QuestionRight method of swapping arrays and classes using pointers Pin
Javier Luis Lopez19-Sep-16 21:35
Javier Luis Lopez19-Sep-16 21:35 
AnswerRe: Right method of swapping arrays and classes using pointers Pin
Richard MacCutchan19-Sep-16 22:19
mveRichard MacCutchan19-Sep-16 22:19 
GeneralRe: Right method of swapping arrays and classes using pointers Pin
leon de boer20-Sep-16 0:41
leon de boer20-Sep-16 0:41 
GeneralRe: Right method of swapping arrays and classes using pointers Pin
Javier Luis Lopez17-Aug-17 23:11
Javier Luis Lopez17-Aug-17 23:11 
The idea is use the pointers to avoid copying all the data.
An example, if there are 3 arrays of pixels: A, B, C and I want to order the arrays I can make the following operation:

C++
if (distance(A,B)>distance(A,C))
   swap(B,C);


I tried this code that swaps anything but it does not compile:
#include <iostream>
#include <string>

using namespace std;

void swap(void *&a,void *&b)
{
	void *x=a;a=b;b=x;
}

void main()
{
	int a[3]={100,101,102};
	int b[3]={200,201,202};
	cout << "a:"<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	cout << "b:"<<b[0]<<" "<<b[1]<<" "<<b[2]<<endl;
	swap((void *) a,(void *) b);
	cout << "a:"<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	cout << "b:"<<b[0]<<" "<<b[1]<<" "<<b[2]<<endl;

	cout << "=== END ===" << endl; getchar();
}


modified 18-Aug-17 5:26am.

GeneralRe: Right method of swapping arrays and classes using pointers Pin
Richard MacCutchan17-Aug-17 23:32
mveRichard MacCutchan17-Aug-17 23:32 
GeneralRe: Right method of swapping arrays and classes using pointers Pin
Javier Luis Lopez20-Aug-17 20:19
Javier Luis Lopez20-Aug-17 20:19 
GeneralRe: Right method of swapping arrays and classes using pointers Pin
Richard MacCutchan20-Aug-17 21:46
mveRichard MacCutchan20-Aug-17 21:46 
AnswerRe: Right method of swapping arrays and classes using pointers Pin
leon de boer20-Sep-16 15:27
leon de boer20-Sep-16 15:27 
GeneralRe: Right method of swapping arrays and classes using pointers Pin
Saravanan Sundaresan24-Sep-16 21:01
professionalSaravanan Sundaresan24-Sep-16 21:01 
QuestionImage processing in C Pin
Ravi Shanakar Singh16-Sep-16 19:23
Ravi Shanakar Singh16-Sep-16 19:23 
AnswerRe: Image processing in C Pin
Jochen Arndt16-Sep-16 22:17
professionalJochen Arndt16-Sep-16 22:17 
AnswerRe: Image processing in C Pin
enhzflep18-Sep-16 15:34
enhzflep18-Sep-16 15:34 
GeneralRe: Image processing in C Pin
leon de boer19-Sep-16 7:07
leon de boer19-Sep-16 7:07 
GeneralRe: Image processing in C Pin
enhzflep19-Sep-16 20:48
enhzflep19-Sep-16 20:48 
GeneralRe: Image processing in C Pin
leon de boer19-Sep-16 23:54
leon de boer19-Sep-16 23:54 
AnswerRe: Image processing in C Pin
CPallini18-Sep-16 21:34
mveCPallini18-Sep-16 21:34 
GeneralRe: Image processing in C Pin
leon de boer19-Sep-16 7:09
leon de boer19-Sep-16 7:09 
GeneralRe: Image processing in C Pin
CPallini19-Sep-16 9:14
mveCPallini19-Sep-16 9:14 
AnswerRe: Image processing in C Pin
leon de boer19-Sep-16 7:17
leon de boer19-Sep-16 7:17 
QuestionCarlos Antollini ADO classes Pin
Member 1111024014-Sep-16 7:03
Member 1111024014-Sep-16 7:03 
AnswerRe: Carlos Antollini ADO classes Pin
Victor Nijegorodov14-Sep-16 7:26
Victor Nijegorodov14-Sep-16 7:26 

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.