how to solve error expression must have class type but it has type "char *"

Q. Write a program to declare classes A,B,C. Each class contains one char array as a data member. Apply multiple inheritances. Concatenate strings of class A and B and store it in class C.

#include<iostream>
using namespace std;
class A
{
public:
char arr1[10]={'a','b','c'};
int i;
void DisplayValues()
{
cout << "Elements of arr1: " << endl;
for (i = 3; i < 3; i++)
{
cout << "arr1 [" << i << "] = " << arr1[i] << endl;
}
}
};
class B: public A
{
public:
char arr2[10] = {'d', 'e', 'f'};
void DisplayValues()
{
cout << "Elements of arr2: " << endl;
for (i = 0; i < 3; i++)
{
cout << "arr2 [" << i << "] = " << arr2[i] << endl;
}
}
};
class C: public B
{
public:
void ConcatenateStrings()
{
cout << "Concatenation of Strings: "<<endl;
arr1.append(arr2);
}
};

I am getting an error expression must have class type but it has type "char *" in arr1.append what can I do next



Read more here: https://stackoverflow.com/questions/68459253/how-to-solve-error-expression-must-have-class-type-but-it-has-type-char

Content Attribution

This content was originally published by Christian at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: