Click here to Skip to main content
15,868,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 5:26
Roberto64_Ge8-Sep-22 5:26 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan8-Sep-22 5:38
mveRichard MacCutchan8-Sep-22 5:38 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 5:43
Roberto64_Ge8-Sep-22 5:43 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 5:37
Roberto64_Ge8-Sep-22 5:37 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan8-Sep-22 5:45
mveRichard MacCutchan8-Sep-22 5:45 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge8-Sep-22 8:04
Roberto64_Ge8-Sep-22 8:04 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan8-Sep-22 23:37
mveRichard MacCutchan8-Sep-22 23:37 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge9-Sep-22 10:30
Roberto64_Ge9-Sep-22 10: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 22:00
mveRichard MacCutchan9-Sep-22 22:00 
GeneralRe: Problem creating an array of "class" Pin
Roberto64_Ge10-Sep-22 0:34
Roberto64_Ge10-Sep-22 0:34 
GeneralRe: Problem creating an array of "class" Pin
Richard MacCutchan10-Sep-22 0:47
mveRichard MacCutchan10-Sep-22 0:47 
QuestionHow can do it in c++? Pin
Member 157580955-Sep-22 6:07
Member 157580955-Sep-22 6:07 
GeneralRe: How can do it in c++? Pin
Richard MacCutchan5-Sep-22 6:43
mveRichard MacCutchan5-Sep-22 6:43 
AnswerRe: How can do it in c++? Pin
Greg Utas5-Sep-22 6:44
professionalGreg Utas5-Sep-22 6:44 
QuestionRe: How can do it in c++? Pin
CPallini5-Sep-22 20:50
mveCPallini5-Sep-22 20:50 
QuestionMessage Closed Pin
4-Sep-22 5:28
Member 149687714-Sep-22 5:28 
AnswerRe: Combining QProcess, qterminal and bluetoothctl...in C++ code Pin
Mircea Neacsu4-Sep-22 6:05
Mircea Neacsu4-Sep-22 6:05 
GeneralMessage Closed Pin
4-Sep-22 6:38
Member 149687714-Sep-22 6:38 
GeneralRe: Combining QProcess, qterminal and bluetoothctl...in C++ code PinPopular
Gerry Schmitz4-Sep-22 8:21
mveGerry Schmitz4-Sep-22 8:21 
AnswerRe: Combining QProcess, qterminal and bluetoothctl...in C++ code Pin
Richard MacCutchan4-Sep-22 21:37
mveRichard MacCutchan4-Sep-22 21:37 
QuestionMessage Closed Pin
29-Aug-22 7:23
Member 1496877129-Aug-22 7:23 
AnswerRe: foreach - basic C++ question Pin
Victor Nijegorodov29-Aug-22 7:40
Victor Nijegorodov29-Aug-22 7:40 
AnswerRe: foreach - basic C++ question Pin
Maximilien29-Aug-22 8:23
Maximilien29-Aug-22 8:23 
AnswerRe: foreach - basic C++ question Pin
CPallini29-Aug-22 20:05
mveCPallini29-Aug-22 20:05 
GeneralMessage Closed Pin
30-Aug-22 3:11
Member 1496877130-Aug-22 3: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.