banner



10.14 Lab: Warm Up: Contacts

Tin can any ane assist, I dont sympathize what I am actually doing and having trouble wrapping my head around the significant of my class and its members and the member functions.
This is my assignment

Assignment Ii - Contacts (Linked List)
You will be building a linked list. Make certain to keep rail of both the head and tail nodes.
(1) Create three files to submit
• Contacts.h - Class declaration
• Contacts.cpp - Class definition
• chief.cpp - main() office
(2) Build the node class for your contacts per the post-obit specifications:
• Parameterized constructor. Parameters are name followed by phone number.
• Public fellow member functions
o InsertAfter()
o GetName() - Accessor
o GetPhoneNumber - Accessor
o GetNext() - Accessor
o PrintContactNode()
• Individual information members
o cord contactName
o cord contactPhoneNum
o ContactNode* nextNodePtr

Case. of PrintContactNode() output:
Name: Roxanne Hughes
Phone number: 443-555-2864

  (3) In main(), prompt the user for three contacts and output the user'south input. Create three ContactNodes and use the nodes to build a linked list.

Example:
Person 1
Enter name:
Roxanne Hughes
Enter telephone number:
443-555-2864
You entered: Roxanne Hughes, 443-555-2864

Person two
Enter name:
Juan Alberto Jr.
Enter phone number:
410-555-9385
You entered: Juan Alberto Jr., 410-555-9385

Person 3
Enter name:
Rachel Phillips
Enter phone number:
310-555-6610
Y'all entered: Rachel Phillips, 310-555-6610

(four) Output the linked list.
Example:
CONTACT Listing
Name: Roxanne Hughes
Phone number: 443-555-2864

Proper noun: Juan Alberto Jr.
Phone number: 410-555-9385

Proper name: Rachel Phillips
Phone number: 310-555-6610

we need three sections
contacts.h given by professor
contacts.cpp
primary.cpp

contacts.h

                      1
two
3
iv
5
vi
7
8
9
10
11
12
13
fourteen
15
16
17
18
19
xx
21
22
23
                                              #ifndef CONTACTS_H                        #define CONTACTS_H                        #include <cord>                        using                        namespace                        std;                        class                        ContactNode {                        public:     ContactNode();     ContactNode(string initName, cord initPhoneNum, ContactNode* nextLoc = 0);                        void                        InsertAfter(ContactNode* nodePtr);     string GetName()                        const;     string GetPhoneNumber()                        const;     ContactNode* GetNext();                        void                        PrintContactNode();                        individual:     string contactName;     string contactPhoneNum;     ContactNode* nextNodePtr; };                                          

what i have come up up with, it tells me i need an initializer earlier GETNAME and GETPHONENUM??
contacts.cpp

                      ane
2
iii
4
v
six
7
8
nine
ten
11
12
13
14
15
16
17
eighteen
nineteen
xx
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
                                              #include<iostream>                        #include <cord>                        #include <vector>                        using                        namespace                        std;                        #include "Contacts.h"                        ContactNode::ContactNode(){ 	contactName =                        "no name"; 	contactPhoneNum =                        "000-000-0000"; 	 	 	 	} 	     ContactNode::ContactNode(cord initName, string initPhoneNum, ContactNode* nextLoc){     	contactName  = initName;     	contactPhoneNum = initPhoneNum;                        this->nextNodePtr =nextLoc;                        return;     }                        void                        ContactNode::InsertAfter(ContactNode* nodePtr){     	ContactNode* tmpNext=0;     	     	tmpNext =                        this                        -> nextNodePtr = nodePtr;     	nodePtr -> nextNodePtr = tmpNext;                        return;     	     }                        void                        ContactNode::string GetName()                        const;                        void                        ContactNode::cord GetPhoneNumber()                        const;      	ContactNode* ContactNode::GetNext(){                        return                        this->nextNodePtr; 	}                        void                        ContactNode::PrintContactNode(){ 		cout <<                        "Full Name: "                        <<                        this->contactName << endl <<                        "Telephone Number: "                        <<                        this-> contactPhoneNum << endl;                        return;                    

you swapped types on your functions.

get name and get telephone are strings in the class header but void below .. string seems to be correct.

                      1
2
3
iv
v
half-dozen
vii
8
9
10
11
12
13
fourteen
15
16
17
eighteen
19
xx
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
xl
41
42
43
                                              #include<iostream>                        #include <string>                        #include <vector>                        using                        namespace                        std;                        #include "Contacts.h"                        ContactNode::ContactNode(){     contactName =                        "no name";     contactPhoneNum =                        "000-000-0000"; }  ContactNode::ContactNode(string initName, string initPhoneNum, ContactNode* nextLoc){     contactName  = initName;     contactPhoneNum = initPhoneNum;                        this->nextNodePtr =nextLoc;                        return; }                        void                        ContactNode::InsertAfter(ContactNode* nodePtr){     ContactNode* tmpNext=0;          tmpNext =                        this                        -> nextNodePtr = nodePtr;     nodePtr -> nextNodePtr = tmpNext;                        return;      }  string ContactNode::GetName()                        const{                        // <--                        return                        contactName; }  cord ContactNode::GetPhoneNumber()                        const{                        // <--                        render                        contactPhoneNum; }  ContactNode* ContactNode::GetNext(){                        render                        this->nextNodePtr; }                        void                        ContactNode::PrintContactNode(){     cout <<                        "Full Name: "                        <<                        this->contactName << endl <<                        "Telephone Number: "                        <<                        this-> contactPhoneNum << endl;                        render; }                    
                      1
2
iii
iv
v
half dozen
vii
8
9
10
11
12
xiii
14
fifteen
16
17
18
19
20
21
22
23
                                              #include <iostream>                        #include <vector>                        #include <string>                        using                        namespace                        std;                        #include "Contacts.h"                        int                        main(){     cout <<                        "Please Enter the Contact information for 3 people:\north";                        //<--                        int                        numCont = 3;                        //<--                        for                        (int                        i = 0; i < numCont; i++){                  cout <<                        "Person "                        << i+1<<                        ":"                        << endl <<                        "Enter Name: "                        << endl;                        //cin >> ????                        }                        render                        0; }                    

Your code is OK as far as information technology goes. To go it to run there need to be a few changes marked with the arrows. Some needs to be completed such as the cin statement to create a new contact and therefor a new node.

Once you can create individual contacts and get them working yous tin then add together them every bit nodes (pointers) to the linked list you build into the Class. You need head node class fellow member etc as for an ordinary linked list

Last edited on

10.14 Lab: Warm Up: Contacts,

Source: https://cplusplus.com/forum/general/212400/

Posted by: rodriguezwiterestich.blogspot.com

0 Response to "10.14 Lab: Warm Up: Contacts"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel