Error: conversion from `PriceFeed*' to non-scalar type `PriceFeed' requested

  • Thread starter Thread starter axed
  • Start date Start date
  • Tags Tags
    Error Type
AI Thread Summary
The error arises from attempting to assign a pointer to a `PriceFeed` object to a variable of type `PriceFeed`. The line `PriceFeed pf = new PriceFeed(tickers);` is incorrect because `new PriceFeed(tickers)` returns a pointer, while `pf` expects an object. To fix this, either use a pointer with `PriceFeed* pf = new PriceFeed(tickers);` or instantiate the object directly without `new` using `PriceFeed pf(tickers);`. This distinction between object and pointer types is crucial in C++. Properly managing memory and object types will resolve the error.
axed
Messages
2
Reaction score
0
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

class PriceFeed
{
public:
PriceFeed(vector<string>& tickers)
{
// init(tickers);
}
}
int main ()
{
vector<string> tickers;
tickers.push_back("AAPL");
tickers.push_back("XOM");

//PriceFeed(tickers);
PriceFeed pf = new PriceFeed(tickers); // Error on this line
system("pause");
//return 0;
}

Can you please tell me where am i going wrong. This is the error
conversion from `PriceFeed*' to non-scalar type `PriceFeed' requested
 
Technology news on Phys.org
new returns pointer.
 
thanks a lot.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
22
Views
3K
Replies
8
Views
2K
Replies
70
Views
5K
Replies
65
Views
7K
Replies
57
Views
4K
Replies
1
Views
1K
Replies
13
Views
2K
Back
Top