Reuniunea a doua agende de telefon

Intrebari despre limbajul C++, standardul C++, STL, OOP in C++ sau alte subiecte nelegate de VisualC++
Post Reply
andreiolar
Junior
Junior
Posts: 1
Joined: 04 Apr 2015, 16:18
Judet: Timiş

Reuniunea a doua agende de telefon

Post by andreiolar » 04 Apr 2015, 16:23

Buna ziua, am nevoie de putin ajutor. Trebuie sa creez o agenta telefonica in care fiecare nume corespunde unui numar. Am facut asta prin creearea unei matrici de tip string. Ideea este ca trebuie sa creeze 2 agende(am ales dimensiunea 2, si le-am creat in main) si trebuie sa fac reuniunea acestor doua agende astfel incat sa rezulte una care sa contina si elem. ag1 si elem. ag2. Imi putetu da niste sfaturi va rog in ceea ce priveste problema ?

Code: Select all

#include "stdafx.h"

using namespace std;

class Agenda{
	string date[20][20];
public:
	Agenda();
	void afisare();
	void reuniune();
};

Agenda::Agenda(){
	int i, j, n;

	cout << "Numarul de intrari: ";
	cin >> n;

	for (i = 0; i < n; i++){
		for (j = 0; j < 2; j++){
			cout << "Date[" << i << "][" << j << "] = ";
			fflush(stdin);
			getline(cin, date[i][j]);
		}
		cout << endl;
	}
	
}

void Agenda::afisare(){
	int i, j;

	for (i = 0; i < 2; i++){
		for (j = 0; j < 2; j++){
			cout << "Date[" << i << "][" << j << "] = ";
			cout << date[i][j] << endl;
		}
		cout << endl;
	}
}

void Agenda::reuniune(){
	
}

void main(){
	Agenda ag1;
	cout << "-----AGENDA 1-----" << endl;
	ag1.afisare();

	Agenda ag2;
	cout << "-----AGENDA 2-----" << endl;
	ag2.afisare();
}



User avatar
MarianMMX
Junior
Junior
Posts: 16
Joined: 27 Mar 2014, 09:50
Judet: Galaţi

Re: Reuniunea a doua agende de telefon

Post by MarianMMX » 14 Apr 2015, 21:29

class InfoUser {
public:
int nrTelefon;
std::string idSkype;
double nrPantof;
}

std::map <string, InfoUser> agenda1;

InfoUser gigi;
gigi.nrTelefon = 0755667788;

agenda1["Gigel"] = gigi;

http://www.cprogramming.com/tutorial/stl/stlmap.html
If you think C++ is not overly complicated, just what is a
protected abstract virtual base pure virtual private destructor
and when was the last time you needed one? — Tom Cargill (1990)

Post Reply