array type not assignable

What does this error mean? Array type char[] not assignable
What could be the workaround to add the elements of a new entry to an array?

This is the function I am working with, with the errors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void AddInput()
{
    char tempTitle[40];
    char tempAuthor[20];
    char tempCategory;
    int sizeInput;
    Entry e;
    
    
    cout << "Enter title: ";
    cin.getline(tempTitle, 80);
    
    cout << "Enter author: ";
    cin.getline(tempAuthor, 80);
    
    cout << "Enter category: ";
    cin.ignore();
    cin.get(tempCategory);
    
    cout << "Enter the size in kb: ";
    cin >> sizeInput;
    
    //assign new title to a new entry
    tempTitle = e.GetTitle(); //error: Array type char[40] not assignable
    //assign a new author to a new entry
    tempAuthor = e.GetAuthor(); //error: Array type char[20] not assignable
    tempCategory = e.GetCategory();
    sizeInput = e.GetSize();
}
Could you provide the source code for class Entry? Specifically the source code for Entry::GetTitle and Entry::GetAuthor.
GetTitle and GetAuthor in class Entry

1
2
3
4
5
6
7
8
9
10
11
const char* Entry::GetTitle() const
/* returns the title stored */
{
    return title;
}

const char* Entry::GetAuthor() const
{

   return author;
}


I guess my main problem is how to add the new entry without having access to the private members of class Entry which are the title, author, category , and size


Last edited on
Are there Set functions? Such as Entry::SetTitle and Entry::SetAuthor?
just one. Set. This is what I have in Set

1
2
3
4
5
6
7
void Entry::Set(const char* t, const char* a, Category c, int sz)
{
    strcpy(title, t); 
    strcpy(author, a); 
    category = c;
    size = sz;
}
It looks like you should do something like this:
e.Set(tempTitle, tempAuthor, tempCategory, sizeInput);
Try replacing lines 23-28 with that line above
Topic archived. No new replies allowed.