473,396 Members | 1,996 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,396 software developers and data experts.

Please help me im getting error as, 'illegal structure operation' ,I'm not able to re

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<iomanip.h>
  4. class sorting
  5. {
  6. private:int n,m[100];
  7. public:  void getdata();
  8.          void sort();
  9.          void display();
  10. };
  11. void sorting::getdata()
  12. {
  13.  cout<<"how many elements?";
  14.  cin>>n;
  15.  cout<<"enter the elements";
  16.        for(int i=0;i<n;i++)
  17.            cin<<m[i];
  18. }
  19. void sorting::sort()
  20. {
  21.  int temp,j;
  22.  for(int i=0;i<n;i++)
  23.     {
  24.         j=i;
  25.            while(j>=i)
  26.         {
.
.
.
.the error is in line 18
Jan 18 '20 #1
7 1986
dev7060
636 Expert 512MB
More details from the OP are required on the environment and code for the other party to reproduce the same error. On compiling the code with TDM-GCC 4.9.2, it shows error: no match for ‘operator<<’. It's because the compiler couldn't find a matching overload for operator<<. This can be solved by the following:

Expand|Select|Wrap|Line Numbers
  1. ...
  2. for(int i=0;i<n;i++)
  3. cin>>m[i];
  4. }
  5. ...
  6.  
Jan 18 '20 #2
SioSio
272 256MB
Differences between standard (ansi) C++ and C (ansi) code.

1.include
<C>
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<iomanip.h>
  4.  
<c++>
Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. #include<conio>
  3. #include<iomanip>
  4.  
2.standard I/O
<c>
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int n;
  5.     printf("how many elements?\n");
  6.     scanf( "%d", &n );
  7.     printf("enter the elements?\n");
  8.     :
  9.     :
  10. }
  11.  
<c++>
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cout << how many elements?";
  7.     cin >> n;
  8.     cout << "enter the elements";
  9.     :
  10.     :
  11. }
  12.  
Jan 20 '20 #3
dev7060
636 Expert 512MB
It may have nothing to do with the error,
This coding looks like a mix of C and C++.
This code is written purely in C++ and is targeting the pre-standard version of C++. The OP is most probably using an ancient compiler like Turbo C++.
Jan 20 '20 #4
SioSio
272 256MB
When I examined about <iostream.h>,
-<iostream> and <iostream.h> are different headers.
-It seems that it was abolished in 2006 (or rather, <iostream.h> has never been a part of the standard since the C ++ international standard was enacted in 1998).
-Only char is supported.

The code below uses <iostream> instead of <iostream.h> and adds "using namespace std;" after the #include statement.
And Use Microsoft Visual C ++ 2017, compilation passed.

Expand|Select|Wrap|Line Numbers
  1. #include "pch.h"
  2. #include <iostream>
  3. #include<conio.h>
  4. #include<iomanip>
  5.  
  6. using namespace std;
  7. class sorting
  8. {
  9. private:int n, m[100];
  10. public: void getdata();
  11.         void sort();
  12.         void display();
  13. };
  14. void sorting::getdata()
  15. {
  16.     cout << "how many elements?";
  17.     cin >> n;
  18.     cout << "enter the elements";
  19.     for (int i = 0;i < n;i++)
  20.     cin >> m[i];
  21. }
  22. void sorting::sort()
  23. {
  24.     int temp, j;
  25.     for (int i = 0;i < n;i++)
  26.     {
  27.         j = i;
  28.         while (j >= i)
  29.         {
  30. :
  31. :
  32.  
Line 17 ("cin >> n;" has been modified to "cin << n;") with the following source,
(Error is "Visual studio: E0349 no operator << matches these operands (but no strings in code)"

Your compilation environment seems very different from mine, so it is unclear if you can use this modified code.
Jan 20 '20 #5
dev7060
636 Expert 512MB
I have pretty much said everything that's required. There is nothing such as a mix of C and C++. A source code file can only be written in one single language with the unique file extension.

Use Microsoft Visual C ++ 2017, compilation passed.
You have made changes to the code by making it compatible to the modern compiler (removing .h from iostream.h, adding using namespace std;, etc.) Using Turbo C++, compilation can be done without even making any change to the code.

Before C++ was standardized, the I/O library was developed as <iostream.h>. Some older compiler continued to distribute the <iostream> header as <iostream.h>. Turbo C++ doesn't support namespaces. Its standard library puts the names in the global namespace. The code by the OP is not a mix of C and C++. The code is purely in C++ targeting the pre-standard version.

You might need to have a look at official docs that reveal the obsolete C++ programming.
Jan 20 '20 #6
SioSio
272 256MB
Hi dev7060.
Thank you for the information.

But,
As mentioned earlier, I have found that <iostream.h> only supports "char".
This could not be confirmed in my compile environment as <iostream.h> is not supported.


https://bytes.com/topic/c/answers/61...eam-h-iostream

Why doesn’t iostream have a .h extension?
https://www.learncpp.com/cpp-tutoria...omment-page-1/
Jan 20 '20 #7
dev7060
636 Expert 512MB
Here's some sample code from the manual of C++ Builder. Differences can be seen like the name of namespace is not mentioned, iostream.h instead of iostream etc.
Expand|Select|Wrap|Line Numbers
  1. #include <sysutils.hpp>
  2. #include <iostream.h>
  3. // non-VCL style classes
  4. class MyBase {
  5. public:
  6. MyBase() { what_am_I(); }
  7. virtual void what_am_I() { cout << "I am a base" << endl; }
  8. };
  9. class MyDerived : public MyBase {
  10. public:
  11. virtual void what_am_I() { cout << "I am a derived" << endl; }
  12. };
  13. // VCL style classes
  14. class MyVCLBase : public TObject {
  15. public:
  16. __fastcall MyVCLBase() { what_am_I(); }
  17. virtual void __fastcall what_am_I() { cout << "I am a base" << endl; }
  18. };
  19. class MyVCLDerived : public MyVCLBase {
  20. public:
  21. virtual void __fastcall what_am_I() { cout << "I am a derived" << endl; }
  22. };
  23. int main(void)
  24. {
  25. MyDerived d;// instantiation of the C++ class
  26. MyVCLDerived *pvd = new MyVCLDerived;// instantiation of the VCL style class
  27. return 0;
  28. }
  29.  
Source: C++ Builder 6 official manual: http://docs.embarcadero.com/products...rsGuide_EN.pdf

Why doesn’t iostream have a .h extension?
Previous replies to this thread and/or own research can answer this question.
Jan 20 '20 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: | last post by:
Hi, I am using VS2003 .NET. I have a union in my files which is generated by YACC. I am getting the following errors while linking using link.exe(Microsoft (R) Incremental Linker Version...
5
by: Sonasang | last post by:
Hi , I am creating a web page with ASP and Javascript.We have shared the foldres containg the code and all our team members are accessing the code. There is no problem for me when i run the...
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
1
by: cppcompiler1000 | last post by:
when i was writing a program i got an error of " illegal structure operation" , in which situation compiler gives this type of error?
2
by: sumanpoonia | last post by:
#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> class complex { int real,imag; public: void read() {
1
by: JacobGoredema | last post by:
Hi, When I try to search my website i am getting the following error. Illegal characters in path highlighting doc.Load(url); Here is my code: public ActionResult Index() { string url =...
1
by: ketanharsoda | last post by:
#include<iostream.h> #include<conio.h> class date { int dd,yy,day,*incr; char *mon; //first latter public: void setptr(date *m); void getdata();
1
by: sd99 | last post by:
The question is to write C++ program using a function ( is_sorted() ) which takes a 1-D array and size as arguments, returns 1 if it is in ascending order, -1 if in descending order or else 0. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.