Click here to Skip to main content
15,500,227 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 6:26
MemberRoberto64_Ge8-Sep-22 6:26 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan8-Sep-22 6:38
mveRichard MacCutchan8-Sep-22 6:38 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 6:43
MemberRoberto64_Ge8-Sep-22 6:43 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 6:37
MemberRoberto64_Ge8-Sep-22 6:37 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan8-Sep-22 6:45
mveRichard MacCutchan8-Sep-22 6:45 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 9:04
MemberRoberto64_Ge8-Sep-22 9:04 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan9-Sep-22 0:37
mveRichard MacCutchan9-Sep-22 0:37 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge9-Sep-22 11:30
MemberRoberto64_Ge9-Sep-22 11:30 
Ok you are right saying that

Richard MacCutchan wrote:
That method is modifying both variables nome_cifrato and cognome_cifrato inline, and you then call setNome and setCognome. But you have already modified the names so you do not need to call the setter methods.


I didn't see it, I get confused writing the code, probably I inteded to use local variables to build cifrated name and surname.

But problem was in this function within the main

C++
void cod (anagrafica arr,string n, string c,int chiave)
{

arr.codifica(n,c,chiave); 

}


that i re-arranged this way

C++
void cod (anagrafica &arr,string n, string c,int chiave)
{

arr.codifica(n,c,chiave); 

}


passing the address to "cod". And about this, I understood the reason (Greg Utas was right about the rules but didn't apply to the real problem because i did not need to change the strings passed to the methods but the instance of the class itself). But now there is another behaviour that confuses me :

In a previous version the following method :

C++
void anagrafica::stampa()
{
 cout<<" nome  cifrato "<<nome_cifrato;
 cout<<" cognome  cifrato "<<cognome_cifrato<<endl;
}


I had to modify in this new version :

C++
void anagrafica::stampa()
{
    string nom = nome_cifrato;
    string cog = cognome_cifrato;
 cout<<" nome  cifrato "<<nom;
 cout<<" cognome  cifrato "<<cog<<endl;
}


because in the first version it was just printing nothing. Now it prints correctly. I just tried without a real knowledge behind, only some kind of sensation but I don't understand why it didn't work before and why it works now.

Anyway thanks for all the efforts/suggestions. I am just starting with c++ in order to help my children in their school exercise.

modified 10-Sep-22 3:10am.

GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan9-Sep-22 23:00
mveRichard MacCutchan9-Sep-22 23:00 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge10-Sep-22 1:34
MemberRoberto64_Ge10-Sep-22 1:34 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan10-Sep-22 1:47
mveRichard MacCutchan10-Sep-22 1:47 
QuestionHow can do it in c++? Pin
Member 157580955-Sep-22 7:07
MemberMember 157580955-Sep-22 7:07 
GeneralRe: How can do it in c++? Pin
Richard MacCutchan5-Sep-22 7:43
mveRichard MacCutchan5-Sep-22 7:43 
AnswerRe: How can do it in c++? Pin
Greg Utas5-Sep-22 7:44
mveGreg Utas5-Sep-22 7:44 
QuestionRe: How can do it in c++? Pin
CPallini5-Sep-22 21:50
mveCPallini5-Sep-22 21:50 
QuestionCombining QProcess, qterminal and bluetoothctl...in C++ code Pin
Member 149687714-Sep-22 6:28
MemberMember 149687714-Sep-22 6:28 
AnswerRe: Combining QProcess, qterminal and bluetoothctl...in C++ code Pin
Mircea Neacsu4-Sep-22 7:05
mvaMircea Neacsu4-Sep-22 7:05 
GeneralRe: Combining QProcess, qterminal and bluetoothctl...in C++ code Pin
Member 149687714-Sep-22 7:38
MemberMember 149687714-Sep-22 7:38 
GeneralRe: Combining QProcess, qterminal and bluetoothctl...in C++ code PinPopular
Gerry Schmitz4-Sep-22 9:21
mveGerry Schmitz4-Sep-22 9:21 
AnswerRe: Combining QProcess, qterminal and bluetoothctl...in C++ code Pin
Richard MacCutchan4-Sep-22 22:37
mveRichard MacCutchan4-Sep-22 22:37 
Questionforeach - basic C++ question Pin
Member 1496877129-Aug-22 8:23
MemberMember 1496877129-Aug-22 8:23 
AnswerRe: foreach - basic C++ question Pin
Victor Nijegorodov29-Aug-22 8:40
MemberVictor Nijegorodov29-Aug-22 8:40 
AnswerRe: foreach - basic C++ question Pin
Maximilien29-Aug-22 9:23
MemberMaximilien29-Aug-22 9:23 
AnswerRe: foreach - basic C++ question Pin
CPallini29-Aug-22 21:05
mveCPallini29-Aug-22 21:05 
GeneralRe: foreach - basic C++ question Pin
Member 1496877130-Aug-22 4:11
MemberMember 1496877130-Aug-22 4:11 

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.