Hello, I am currently working on a program in which allows one to generate a new page after every 280 characters. In addition new page at 274 characters with no spaces and special characters as in punctuations. Yet I am getting errors with my pointers please help. :(
The current errors I am receiving are that:
Unqualified-id for the "Tweet = new class Tweet[100];"
also an undeclared identifier for 'arr'
this line is wrong you do not need the [] braces after declaring a pointer so it would become the following line below,also be careful with capitals and lower case.
Tweet *tweets = new Tweet;
also
Tweet = newclass Tweet[100];
you do not need to put the class keyword before Tweet this is creating a 100 new Tweets on the heap/free store memory,but this is wrong because you just specified the class name and not a variable name,
Okay I did what you asked but after that I am getting more errors.
The errors I am now getting from my terminal are:
twitter.cpp; line 17; error: indirection requires pointer operand ('Tweet' invalid)
"*tweets[0] = message.substr(0,280);"
twitter.cpp; line 18; error: reference to overloaded function could not be resolved; did you mean to call it?
"*count = 1;"
twitter.cpp; line 28; error: no viable overloaded '='
"tweets[x] = message;"
class Tweet
twitter.hpp; line 8; note: candidate function (the
implicit copy assignment operator) not viable:
no known conversion from 'std::__1::string'
(aka 'basic_string<char, char_traits<char>,
allocator<char> >') to 'const Tweet' for 1st
argument
twitter.cpp; line 37; error: no viable overloaded '='
"tweets[x] = message.substr(0,280);"
twitter.hpp:8:7: note: candidate function (the
implicit move assignment operator) not viable:
no known conversion from
'std::__1::basic_string<char>' to 'Tweet' for
1st argument
class Tweet
twitter.cpp; line 43; error: no viable overloaded '='
"tweets[x] = message.substr(0,280);"
twitter.cpp; line 69; error: member reference type 'Tweet *' is a pointer; did you mean to use '->'?
"...&& tweets.rfind(p) > tweets.rfind(s) && tweet..."
twitter.cpp; line 69; error: no member named 'rfind' in 'Tweet'
error: member reference type 'Tweet *'
is a pointer; did you mean to use '->'?
"...> tweets.rfind(q) && tweets.rfind(p) > tweets..."
"...&& tweets.rfind(p) > tweets.rfind(q) && tweet..."
"...&& tweets.rfind(p) > tweets.rfind(q) && tweet..."
"...> tweets.rfind(e) && tweets.rfind(p) > tweets..."
"if (tweets.rfind(p) > tweets.rf..."
"if (tweets.rfind(p) > tweets.rf..."
"...if (tweets.rfind(p) > tweets.rfind(e) && twee..."
twitter.cpp; line 63; error: no viable overloaded '='
"...tweets[x] = message.substr(0,274);"
twitter.cpp; line 37: error: no viable overloaded '='
"tweets[x] = message.substr(0,280);"
twitter.cpp; line 55: error: no viable overloaded '='
"tweets[x] = message.substr(0,280);"
I never seen this error before:
/Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:1244:1: note:
possible target for call
count(_InputIterator __first, _InputIterator ...
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/__bit_reference:307:1: note:
possible target for call
count(__bit_iterator<_Cp, _IsConst> __first, ...
Here is the code that I corrected.
#ifndef TWITTER_HPP // This code prevents multiple includes of twitter.hpp
#define TWITTER_HPP
#include <iostream>
#include <string>
using namespace std;
}
TwitterManager(string u, string m)
{
username = u;
message = m;
length = m.length();
Tweet *tweet = new Tweet[100];
}
void display();
};
// Insert code here that creates the Tweet and TwitterManager classes.