Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please convert this following C++ program into C. Thank you for the help Contacts.cpp #include #include Contacts.h using namespace std; ContactNode::ContactNode(){ nextNodePtr=NULL; } ContactNode::ContactNode(string name,

Please convert this following C++ program into C.

Thank you for the help

Contacts.cpp

#include #include "Contacts.h" using namespace std; ContactNode::ContactNode(){ nextNodePtr=NULL; } ContactNode::ContactNode(string name, string phoneNum){ contactName=name; contactPhoneNum=phoneNum; }

void ContactNode::InsertAfter(ContactNode *nextNode){ ContactNode *temp; if(nextNodePtr==NULL) nextNodePtr=nextNode; else{ temp=nextNodePtr; while(temp!=NULL){ temp=temp->GetNext(); } temp=nextNode; } }

string ContactNode::GetName(){ return contactName; }

string ContactNode::GetPhoneNumber(){ return contactPhoneNum; }

ContactNode* ContactNode::GetNext(){ return nextNodePtr; }

void ContactNode::PrintContactNode(){ ContactNode *temp; cout<<"Contact Name: "<PrintContactNode(); }

Contacts.h

#ifndef Contact_H #define Contact_H #include using namespace std; class ContactNode{ public: ContactNode(); //constructor ContactNode(string name, string phone); void InsertAfter(ContactNode*); string GetName(); string GetPhoneNumber(); ContactNode* GetNext(); void PrintContactNode(); private: string contactName; string contactPhoneNum; ContactNode* nextNodePtr; }; #endif

Main.cpp

#include #include "Contacts.cpp" using namespace std;

int main(){ ContactNode contactList; string name; string phoneNum; for(int i=0;i<3;i++){ cout<<"Enter name: "; cin>>name; cout<<"Enter phone number: "; cin>>phoneNum; contactList.InsertAfter(new ContactNode(name,phoneNum)); } cout<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions