Operaciones Básicas:
Veamos estos métodos programados en C++:
- Incluir un objeto en el vector
- Saber el tamaño del vector
- Borrar el ultimo objeto incluido en el vector
- Saber cual fue el primer objeto incluido en el vector
- Saber cual fue el ultimo objeto incluido en el vector
- Salir
#include iostream#include vector#include "Persona.h"using namespace std;int main(){vectorPersona Vec_Persona;Persona ObjetoPersona;int opcion;//Variables a usar en los métodos de inserciónstring nombre, cedula;int edad;//////////////////////////////////////////////do{cout "\n\n=========OPERACIONES BASICAS CON VECTORES==========\n";cout "==============Menu de opciones ====================\n";cout "1 Incluir un objeto en el vector \n";cout "2 Saber el tamaño del vector \n";cout "3 Borrar el ultimo objeto incluido en el vector \n";cout "4 Saber cual fue el primer objeto incluido en el vector \n";cout "5 Saber cual fue el ultimo objeto incluido en el vector \n";cout "6 Salir \n";cin opcion;switch(opcion){case 1: cout "Ingrese el nombre de la persona: \n"; cin nombre; ObjetoPersona.SetNombre(nombre); cout "Ingrese la cedula de la persona: \n"; cin cedula; ObjetoPersona.SetCedula(cedula); cout "Ingrese la edad de la persona: \n"; cin edad; ObjetoPersona.SetEdad(edad); Vec_Persona.push_back(ObjetoPersona);break;case 2: cout "El vector contiene: " Vec_Persona.size() " objetos en total \n";break;case 3: if(Vec_Persona.empty()) //La funcion empty nos indica mediante un valor booleano true o false si el vector esta vacio o no cout "No se pueden eliminar objetos por que el vector esta vacio \n"; else{ cout "Se ha eliminado a " Vec_Persona[Vec_Persona.size() - 1].GetNombre() endl; Vec_Persona.pop_back(); }break;case 4: if(Vec_Persona.empty()) cout "Ingrese un objeto antes de elegir esta opcion \n"; else cout "El primer objeto agregado es: " Vec_Persona.front().GetNombre() endl;break;case 5: if(Vec_Persona.empty()) cout "Ingrese un objeto antes de elegir esta opcion \n"; else cout "El último objeto incluido es: " Vec_Persona.back().GetNombre() endl;break;}}while(opcion != 6);}
Explicación:
Veamos la ejecución del programa:
#ifndef PERSONA_H_#define PERSONA_H_#include iostreamusing namespace std;class Persona {private: string nombre, cedula; int edad;public: Persona(); void SetNombre(string nom); string GetNombre(); void SetCedula(string ced); string GetCedula(); void SetEdad(int eda); int GetEdad();};#endif /* PERSONA_H_ */
#include "Persona.h"Persona::Persona() { // TODO Auto-generated constructor stub}void Persona::SetNombre(string nom) { nombre = nom;}string Persona::GetNombre() { return nombre;}void Persona::SetCedula(string ced) { cedula = ced;}string Persona::GetCedula() { return cedula;}void Persona::SetEdad(int eda) { edad = eda;}int Persona::GetEdad() { return edad;}
- Elemento menor de un vector en C++ (min_element)
- Elemento mayor de un vector en C++ (max_element)
- Algoritmo - Factorial de un número en C++
- Matriz de la relación predecesor inmediato en c++
- Matriz de accesibilidad de un Digrafo en c++
- Elevar un número a una potencia en C++
- 4 Ejercicios Básicos de Programación Orientada a Objetos en c++
attorney lawyer mesothelioma Casino reviews mesothelioma claim Mobile casino Donate Car to Charity California mesothelioma symptoms DONATING USED CARS TO CHARITY houston mesothelioma attorney Best social media platforms for business Make money online Australia Better Conference Calls mesothelioma personal injury lawyers Best Criminal Lawyers in Arizona Webex Costs Online casino cheap car insurance in virginia firm law mesothelioma DONATE YOUR CAR SACRAMENTO HOME PHONE INTERNET BUNDLE Met Auto Life insurance co Lincoln HARDDRIVE DATA RECOVERY SERVICES google affiliate utah mesothelioma lawyer broward county dui lawyer Cheap domain registration hosting Service business software structured settlements annuities motor insurance quotes car insurance in south dakota WebEx costs Custom Christmas cards Criminal defense lawyer DONATE CAR FOR TAX CREDIT DUI lawyer Mortgage Adviser Casino auto insurance cost by state Criminal lawyer Php programmers Car Insurance Quotes Utah online criminal justice degree california law lemon Structures Annuity Settlement Online Classes la personal injury lawyer Home Phone Internet Bundle Live casino att call conference Motor Replacements Psd to html Hire php developers Tech school Personal Injury Law Firm DONATE OLD CARS TO CHARITY Hire php programmers mesothelioma law firms HOW TO DONATE A CAR IN CALIFORNIA boca raton personal injury attorney mesothelioma attorney Social media platforms for business mortgage adviser Cheap Car Insurance in Virginia Bankruptcy lawyer adverse credit remortgage selling annuity asbestos lawyers VIRTUAL DATA ROOMS Dwi lawyer Donate Cars in MA motorcycle accident lawyer san francisco MORTGAGE ADVISER Mesothelioma Law Firm Php programmers for hire Car Insurance in South Dakota structured settlement blog DONATE YOUR CAR FOR MONEY Hire php developer Mortgage adviser MESOTHELIOMA LAW FIRM mesothelioma attorneys Cheap Auto Insurance in VA Injury Lawyers WEBEX COSTS car insurance quotes colorado Computer science classes online Royalty Free Images Stock CRIMINAL DEFENSE ATTORNEYS FLORIDA STRUCTURED ANNUITY SETTLEMENT NEUSON mesothelioma lawsuits paperport promotional code Seo companies Custom WordPress theme designer Criminal lawyer Miami Best Seo company Html email Business finance group primary pulmonary hypertension mesotheloma Car Insurance Quotes ASBESTOS LAWYERS Life Insurance Co Lincoln online colledges ROYALTY FREE IMAGES STOCK refinance with bad credit New social media platforms yahoo web hosting Email bulk service most profitable internet business semi truck accident lawyers AUTOMOBILE ACCIDENT ATTORNEY bus accident attorney los angeles DAYTON FREIGHT LINES Seo services earthlink business internet car insurance companies Dayton Freight Lines structured settlement annuity companies Business management software Seo company Best social media platforms integrated ehr Proud Italian cook Online Colleges Social media examiner motorcycle lawyer los angeles Car Accident Lawyers Data Recovery Raid auto accident attorney Donating Used Cars to Charity Dayton freight lines orlando criminal attorney WordPress themes for designers Online Christmas cards Italian cooking school DONATING A CAR IN MARYLAND Photo Christmas cards Online Motor Insurance Quotes Dallas mesothelioma attorneys mesothelioma settlements WordPress hosting Psd to WordPress Social media management mesothelioma litigation alabama mesothelioma lawyer Royalty free images stock Social media platforms Massage School Dallas Texas Christmas cards EMAIL BULK SERVICE Annuity Settlements donate old cars to charity Social media strategies WordPress theme designers Adobe illustrator classes better conferencing calls life insurance quotes accident lawyers in los angeles asbestos mesothelioma lawsuit Learning adobe illustrator Social media tools Social media campaigns anti spam exchange server Virtual Data Rooms Donate Car for Tax Credit Donate Your Car for Kids Donating a Car in Maryland Donate Your Car Sacramento How to Donate A Car in California ANNUITY SETTLEMENT Sell Annuity Payment BETTER CONFERENCING CALLS personal injury solicitor Asbestos Lawyers DONATE CARS IN MA Car Insurance Quotes Colorado Nunavut Culture Hard drive Data Recovery Services forensics online course truck accident attorney los angeles donate your car for money Donate a Car in Maryland Car Insurance Quotes MN Cheap Domain Registration Hosting CAR INSURANCE QUOTES UTAH Donate Cars Illinois domain registration yahoo World trade center footage Criminal Defense Attorneys Florida Auto Mobile Insurance Quote mesothelioma lawyer chicago Met auto virtual data rooms Holland Michigan College benchmark lending Donate a car in Maryland offshore accident lawyer Paperport Promotional Code los angeles motorcycle accident lawyer Insurance Companies mesotheliama Gas/Electricity World Trade Center Footage phd in counseling education motor replacements MASSAGE SCHOOL DALLAS TEXAS Psychic for Free asbestos lung cancer personal injury attorney springfield mo car accident lawyer san bernardino Donate Old Cars to Charity Forensics Online Course structured settlement investments Low Credit Line Credit Cards Dallas Mesothelioma Attorneys Donate your Car for Money chicago hair laser removal CHEAP CAR INSURANCE IN VIRGINIA city college in miami Dedicated Hosting Dedicated Server Hosting Personal Injury Lawyers PHD on Counseling Education mesothelioma claims Neuson Automobile Accident Attorney Car Insurance Quotes PA mesothelioma care Email Bulk Service life insurance co lincoln Home phone internet bundle Cheap Car Insurance for Ladies Register Free Domains mesothelioma law firm Futuristic Architecture CAR ACCIDENT LAWYERS Car Donate Online College Course Auto Accident Attorney ONLINE MOTOR INSURANCE QUOTES See more at http//wwwginfostopnet/ dallas mesothelioma attorneys Motor Insurance Quotes best criminal lawyer in arizona Asbestos Lung Cancer Attorney mesothelioma trial attorney PhD in counseling education new york mesothelioma law firm Online Criminal Justice Degree
· Mortgage Adviser Insurance Credit Software donate old cars to charity Cord Blood Blogs Based On Donations mesothelioma survival rates Donate Degree Donate Car to Charity California Online casino Loans mesothelioma suit Mortgage Gas/Electricity Recovery Data Recovery Services Online Classes DUI ATTORNEY ORLANDO · Better Conferencing Calls Lawyer Transfer Classes Claim Hosting Attomey STRUCTURED ANNUITY SETTLEMENT structured settlements annuities small business administration sba Technology Blogs Technology STRUCTURE SETTLEMENTS Rehab ACCIDENT AND INJURY ATTORNEY Treatment Conference Call Bluehost Laws and lawyers Trading Digital Photography domain registration yahoo Attormey Auto insurance affiliate program Mesothelioma Law Firm Politics WebHostingHub Donate Car for Tax Credit Insurance Blogs Coupons Student Loans Cooking Recipes ANNUITY SETTLEMENT NUNAVUT CULTURE DAYTON FREIGHT LINES structured settlement annuity companies mesothelioma attorneys california structured settlement buyer Fatcow mesothelioma claim · World Trade Center Footage All topics related to traffic from USA
No hay comentarios:
Publicar un comentario