Question

C++

I create a class object and I store my class object in an array like this


employee emp1; employee emp2; employee emp3; employee emp4; employee emp5; employee emp6; // array employee ListEmployee Info

if I want to delete data for one of the array
for example for emp1

do I write the delete function like this ?


case 1: :emp1.setName(null, null, null); emp1.setAddress (, null null, null, 0); emp1.setAddressApt (, null, e,

Can anyone help me come up with a delete record function?

employee emp1; employee emp2; employee emp3; employee emp4; employee emp5; employee emp6; // array employee ListEmployee Info[6]6 emp1, emp2, emp3,emp4, emp5, emp6 )
case 1: :emp1.setName("null", "null", "null"); emp1.setAddress (, "null "null", "null", 0); emp1.setAddressApt (, "null", e, "null", "null", 0); emp1.setPhoneNumber(); empl.setGrade('N'); emp1.setDate (, 0, 0); emp1.setDesignation("nul1"); emp1.setLoan(); emp1.setBsalary (e); emp1.setNsalary (e); emp1.setAllowance(0); case 2: :emp2.setName("null", "null", "null"); emp2.setAddress (, "null", "null", "null", e); emp2. setAddressApt (, "null", e, "null", "null", 0); emp2.setPhoneNumber() emp2.setGrade('N'); emp2.setDate (, 0, 0); emp2. setDesignation("nul1"); emp2.setLoan(); emp2.setBsalary(); emp2.setNsalary (0); emp2.setAllowance (0);
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In a Simple way the Reset functionality can be implemented as follows

This is by using clear public function inside the class employee.Therefore clear record will be small.

class employee

{

string name;

string address;

string addressapt;

long phno;

char grade;

int Date;

string designation;

int loan;

int bSalary;

int nSalary;

int allowance;

public:

void clear()

{

name = "";

address = "";

addressapt = "";

phno = 0;

grade = 'N';

Date = 0;

designation = "";

loan = 0;

bSalary = 0;

nSalary = 0;

allowance = 0;

}

};


void deleteRecord(employee emp[],int nRecordNumber)

{

emp[nRecordNumber].clear();

}

Add a comment
Know the answer?
Add Answer to:
C++ I create a class object and I store my class object in an array like this if I want to delete data for one of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Pleas help I need to create and array to add to my code something like this...

    Pleas help I need to create and array to add to my code something like this for (i = 0; i < NUM_THREADS; ++i) { thr_data[i].tid = i; if ((rc = pthread_create(&thr[i], NULL, thr_func, &thr_data[i]))) { fprintf(stderr, "error: pthread_create, rc: %d\n", rc); return EXIT_FAILURE; ::::::::: CODE ::::::::::::: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h>    int sharedVar = 0; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* thread handler */ void *threadHandler(void *vargp) {    int i = 0;    pthread_mutex_lock(&mutex);   ...

  • IN C++ Create a class to act as a generic array (i.e. the user will be...

    IN C++ Create a class to act as a generic array (i.e. the user will be able to choose the data type to be stored by passing the appropriate template argument. Integer template arguments will also be used to set the upper and lower bounds of the array. Provide all necessary functionality to allow the class to act as an array ([] operator, = operator etc.). The array does not need to provide input or output methods to act on...

  • In python, how do you create an array of unknown dimensional size? I want to create...

    In python, how do you create an array of unknown dimensional size? I want to create an array of unknown dimensional size based on a number I recieve. To elaborate, let's say n = 2, it will output a 3D array {true, true, true}. If n = 3, then its output will be a 4D array {true, true, true, true}. Whatever the n value is, the return value will be an array of n + 1 dimensional size. How would...

  • JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array...

    JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array storing elements in the list • topOfStack: an int value representing the location of the stack top in the array • INITIAL_CAPACITY: the default capacity of the stack public class ArrayBasedStack <E> { private E[] data; private int topOfStack; private static final int INITIAL_CAPACITY = 5; } Add a constructor that will initialize the stack with a user-defined initial capacity. The top of the...

  • An array of class objects is similar to an array of some other data type. To...

    An array of class objects is similar to an array of some other data type. To create an array of Points, we write Point parray [4]; To access the object at position i of the array, we write parray [i] and to call a method on that object method, we write parray [i]. methodName (arg1 , arg2 , ...) ; To initialize an array of objects whose values are known at compile time, we can write Point parray [4] =...

  • C++ Please help. 1) Create an array to store 10 Point2D points (the Point2D class from...

    C++ Please help. 1) Create an array to store 10 Point2D points (the Point2D class from A6). Set the coordinates from 0,0 to 9,9. Move all the points left 5 units and up 10 units. Print their new location. 2) Make a new class Point3D which inherits from the Point2D class. The class has one more data member for the z coordinate. There are two constructors, a default one and one with 3 coordinates. Add the new member functions getZ,...

  • 4. Create a Business class. This class should store an array of Employee objects. Add a...

    4. Create a Business class. This class should store an array of Employee objects. Add a method to add employees to the Business, similar to addFoodItem in the Meal class. Add two more methods for the Business class: getHighestPaid(), which returns the Employee who has been paid the most in total, and getHighestTaxed(), which returns the Employee who has been taxed the most in total. Note: you do not need to handle the case of ties. These are all the...

  • Using Python. 3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type...

    Using Python. 3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type Student so that you do not create duplicate objects. Test your list with the provided program. You will find example code for a single-linked list of integers in Moodle that you can base your solution on. For your find methods, you can either...

  • Array with Iterator. Java style Implement an array data structure as a class JstyArray<E> to support...

    Array with Iterator. Java style Implement an array data structure as a class JstyArray<E> to support the Iterable interface such that the following code works: JstyArray<Integer> data; data = new JstyArray<Integer>(10); for (int i = 0; i < 10; ++i) { data.set(i, new Integer(i) ); } int sum = 0; for ( int v : data ) { if (v == null) continue; // empty cell sum += v; } The iterator provided by this class follows the behaviour of...

  • Introduction In this lab, you are supposed to implement a graph class with the data structure...

    Introduction In this lab, you are supposed to implement a graph class with the data structure implemented before like linked list and queue. graph The class graph contains three member variables: linkedList *adjacentVertices; //an array of linked list. For a vertice i, adjacentVertices[i] stores the linked list that contains all other vertices connected to vertice i. int numVertices; //The number of vertices in the graph. int maxNumVertices; //The maximum number of vertices the graph can hold. Following public methods are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT