473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Push back

Hi!

I'm implementing a new method of data input for my program using the
push_back(int) function.

When I compile my code (Borland free compiler), I get:

"Could not find a match for 'vector<facetinfo, allocator<facetinfo>
::push_back(int)' in function main()"


Am I missing something?

TIA

#include <stdlib>
#include <math>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>

using std::cout;
using std::cin;
using std::ifstream;
using std::string;
using namespace std; //I don't need the previous lines, right?

struct facetInfo {
double v1x;
double v1y;
double v1z;
double v2x;
double v2y;
double v2z;
double v3x;
double v3y;
double v3z;
double nox;
double noy;
double noz;
}; // Semicolon necessary
int main()
{
char fileName[255];
cout << "Enter the name of the input *.STL file (including extension): ";
cin >> fileName;
ifstream inf(fileName);
cout << fileName;
char buffer[128];
char * ehWhy;
int vertNum=1;
int facetNum=0;
int normFlag=0;
int vertFlag=0;
int compFlag=0;
double holder;
string ncheck = "normal";
string vcheck = "vertex";

// 10234 facets
vector<facetInfo> mySurface;
while(!inf.getline(buffer, 128, ' ').eof())
{
if (buffer == ncheck)
{
normFlag=1;
compFlag=1;
vertNum=1;
if (facetNum !=0)
{
mySurface.push_back(facetNum);
}
...... etc
}
}

Alex

--
Reply to:alex an.ti livingstone sp@am btinternet.com cutting the usual...
Jul 19 '05 #1
7 14545
{AGUT2} {H}-IWIK escribió:
I'm implementing a new method of data input for my program using the
push_back(int) function.


A vector of facetInfo does not have a push_back(int) function, it has a
push_back(facetInfo).

Regards.
Jul 19 '05 #2
{AGUT2} {H}-IWIK wrote:
Hi!

I'm implementing a new method of data input for my program using the
push_back(int) function.

When I compile my code (Borland free compiler), I get:

"Could not find a match for 'vector<facetinfo, allocator<facetinfo>
::push_back(int)' in function main()"

Am I missing something?

TIA

#include <stdlib>
#include <math>


The previous 2 headers don't exist in C++. You need to add either a 'c'
on the front or a '.h' on the back of each.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>

using std::cout;
using std::cin;
using std::ifstream;
using std::string;
using namespace std; //I don't need the previous lines, right?
The 'using namespace std' covers the previous using lines. It's
generally better not to bring in the entire namespace, though.

struct facetInfo {
double v1x;
double v1y;
double v1z;
double v2x;
double v2y;
double v2z;
double v3x;
double v3y;
double v3z;
double nox;
double noy;
double noz;
}; // Semicolon necessary
Looks like you could break that up a little more... if you had a Point
class or something like that:

struct facetInfo {
Point v1;
Point v2;
Point v3;
Point no;
};

Or

Strict facetInfo {
Point v[3];
Point no;
};

Could make it much simpler to deal with.


int main()
{
char fileName[255];
You #included <string>. Why not use it? This is an ideal place.

string fileName;
cout << "Enter the name of the input *.STL file (including
extension): ";
cin >> fileName;
ifstream inf(fileName);
ifstream inf(fileName.c_str());

You also need to check that it opened successfully.
cout << fileName;
char buffer[128];
string buffer;

Or

vector<char> buffer;

Or

vector<char> buffer(128);

might be better, depending on how you intend to use it.

(In fact, scanning ahead it looks like you should definitely use 'string
buffer'.)
char * ehWhy;
int vertNum=1;
int facetNum=0;
OK...
int normFlag=0;
int vertFlag=0;
int compFlag=0;
double holder;
string ncheck = "normal";
string vcheck = "vertex";
It kind of looks like you want these to be constants. If so, declare
them const.

// 10234 facets
vector<facetInfo> mySurface;
OK...
while(!inf.getline(buffer, 128, ' ').eof())
A few problems here. One, don't test for eof. There are other ways file
input can fail - you should check for general failure. Two, use
std::getline instead of std::istream::getline. It reads into a string
instead of a char array, and automatically resizes the string:

while (getline(inf, buffer, ' '))
{
if (buffer == ncheck)
{
normFlag=1;
compFlag=1;
vertNum=1;
if (facetNum !=0)
{
mySurface.push_back(facetNum);
Not OK. facetNum is an int. mySurface contains facetInfos, not ints.
}
...... etc
}
}

Alex


-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #3
> A vector of facetInfo does not have a push_back(int) function, it has a
push_back(facetInfo).


Thank you _so_ much!

Alex

--
Reply to:alex an.ti livingstone sp@am btinternet.com cutting the usual...
If you fancy a chat, #agut on quakenet :)
Jul 19 '05 #4
>> #include <stdlib>
#include <math>


The previous 2 headers don't exist in C++. You need to add either a 'c'
on the front or a '.h' on the back of each.


I understand that .h headers stopped being used with the ratified C++ - I
take it that the cmath and cstdlib are the new templates(headers??) that
replace them?

Thanks,

Alex.

--
Reply to:alex an.ti livingstone sp@am btinternet.com cutting the usual...
Jul 19 '05 #5
{AGUT2} {H}-IWIK wrote:
#include <stdlib>
#include <math>

The previous 2 headers don't exist in C++. You need to add either a
'c' on the front or a '.h' on the back of each.

I understand that .h headers stopped being used with the ratified C++ -


Not quite. There are still 18 headers taken from C that end in '.h'
(including <math.h> and <stdlib.h>), but they are deprecated in favor of
version that drop the '.h' and add a 'c' to the front (e.g., <cmath> &
<cstdlib>.
I take it that the cmath and cstdlib are the new templates(headers??)
that replace them?


They are headers, not templates.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #6
Hello,

{AGUT2} {H}-IWIK <al********************@ambtinternet.com> wrote in message news:<op**************@mercury.nildram.net>...
#include <stdlib>
#include <math>
This should be cstdlib and cmath instead.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>

using std::cout;
using std::cin;
using std::ifstream;
using std::string;
using namespace std; //I don't need the previous lines, right?
That's right.
struct facetInfo {
double v1x;
double v1y;
double v1z;
double v2x;
double v2y;
double v2z;
double v3x;
double v3y;
double v3z;
double nox;
double noy;
double noz;
}; // Semicolon necessary
int main()
{
char fileName[255];
cout << "Enter the name of the input *.STL file (including extension): ";
cin >> fileName;
ifstream inf(fileName);
cout << fileName;
char buffer[128];
char * ehWhy;
int vertNum=1;
int facetNum=0;
int normFlag=0;
int vertFlag=0;
int compFlag=0;
double holder;
string ncheck = "normal";
string vcheck = "vertex";

// 10234 facets
vector<facetInfo> mySurface;
while(!inf.getline(buffer, 128, ' ').eof())
{
if (buffer == ncheck)
{
normFlag=1;
compFlag=1;
vertNum=1;
if (facetNum !=0)
{
mySurface.push_back(facetNum);
Not possible. You declared mySurface to be a vector consisting of
facetInfo, so push_back should receive an instance of this class. You
are giving it an int here.
}
...... etc
}
}


Have a nice day,
Chris Dams
Jul 19 '05 #7
> I understand that .h headers stopped being used with the ratified C++ - I
take it that the cmath and cstdlib are the new templates(headers??) that
replace them?


They are the new headers.
One thing

cmath and cstdlib are such that you will need using clauses unlike math.h
and stdlib.h

Stephen Howe
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Will | last post by:
Hi, Sorry to be a pest... But I can figure this out. I'm pushing to a stack. then I need to check to see if the word is a palindrome. Is the code below correct? if so, how can I check the...
4
by: Ben Kim | last post by:
Hello all, We are re-developing a software product that requires push technology (wireless and hardwired). Microsoft used to support this technology in IE but dropped it for whatever reason. ...
4
by: Mark Siler | last post by:
First let me say I'm not a developer. I'm looking for someone that can either do this for me or point me to a technology that can. I'm in need of a way via the Internet to push a screen or webpage...
6
by: zerobinary | last post by:
sorry, but i can't find any info on push back function plz help
1
by: Ashes2Ashes | last post by:
Hi, I've created a webpage where the user can enter an number/word into an address bar and it would appear somewhere else on the page - I also have back and forward buttons on the page (similar to...
4
by: Jeff | last post by:
I seem to recall that IE at one time did not support push. How far back do we have to go before we lose push? Is it IE4? Jeff
12
by: MyMarlboro | last post by:
hi... i have problem in using push function. @aa= qq (aa bb cc); push (@aa, 'dd'); print Dumper (@aa); exit; result as follow: $VAR1 = 'aa bb cc';
5
by: ludvig.ericson | last post by:
Hello, My question concerns asynchat in particular. With the following half- pseudo code in mind: class Example(asynchat.async_chat): def readable(self): if foo:...
0
by: davy zhang | last post by:
I wrote this server to handle incoming messages in a process using multiprocessing named "handler", and sending message in a Thread named "sender", 'cause I think the async_chat object can not...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.