• Register
1 vote

Problem :

I am trying to enter numbers for my array br_el[6], and also I want it to show me for what object I am entering my number! So when I want to compile it gives me the below error:

"[Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string}' through '...'"

 I have already tried to declare the string qr_naziv[6]; but my string didn't even bold so it didn't work for me, so looking for the solution on my error ?

6 5 3
7,540 points

1 Answer

0 votes

Solution :

I had also faced the similar issue in the recent past. I did lot of research on it and found the solution on it. This is the very common problem with the people getting started.

I must tell you that C functions are not acquainted with the C++ structures. You should do as the below:

for(j = 0; j < 6;j++) {
    printf("Input your number for %s =", qr_naziv[j].c_str());
    scanf("%d", &br_el[j]);


Please notice the call to your method c_str() on a each std::string qr_naziv[j], which returns the const char * to the null-terminated character array with the data equivalent to those stored in a string -- a C-like string.

If you follow the solution then your issue will be resolved.

9 7 4
38,600 points

Related questions

0 votes
1 answer 5 views
I am continiously getting this error array to string conversion error in PHP. How can i solve it?
asked Oct 4 Daniel Anderson 4k points
1 vote
1 answer 24 views
Problem: Hello all, I am struggling to solve a problem for the last thirty minutes using the c++ programing language. I was thinking of writing a program that will read the defined string and iterate through it and print all the words separately. Suppose I initialize a string with ... it very much How do you it or suggest me an easy way to do that. I look forward. Thanks for your kind assistance.
asked Jun 15 adamSw 11.3k points
0 votes
1 answer 15 views
I have a class called Pokemon, where I put 2 constructors, the first is for initialization and the other receives the name of a pokemon and completes it class Pokemon { private: string type; string advantage1; string advantage2; string resistance1; string resistance2; string ... const char [8]' to non-scalar type 'Pokemon' requested error: conversion from 'const char [9]' to non-scalar ty
asked Aug 14 game 4.6k points
0 votes
1 answer 8 views
My program consists of a menu that has: To register. Unsubscribe. Modify. To show. Leave. And the Person class with its constructors and methods. The Person class is something like this: Class Persona { private: char * dni; char * fullname; int age; public: Person (char ... is entered in the array but it doesn't work either. I hope you have understood me more or less and thank you very much!
asked Aug 17 game 4.6k points
0 votes
1 answer 9 views
I noticed that in the loop of STATEMENT 1 we put (* p ++) and supposedly this represents that it is going to loop through an element of the array. But I start to think that the logical thing would be that if my pointer is starting at position [0]; in the loop of DECLARATION 1 I would start saving it in position ... position" << i << ":"; cin >> * p;         * p ++;     } * /          return 0; }
asked Aug 14 game 4.6k points