473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Expected unqualified-id for sum of numbers in 2D matrix

1 New Member
This code should return sum of all the numbers in a 5x5 matrix :

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. class solution{
  4.     int sum = 0; 
  5. for(int i=0;i<5;i++){
  6.     for(int j=0;j<5;j++){
  7.         sum += arr[i][j];
  8.     }
  9.  
  10. }
  11. };
  12.  
  13. int main(){
  14.     int arr[5][5];
  15.     for(int i=0; i<5; i++) for(int j=0; j<5; j++) std::cin >> arr[i][j];
  16.     std::cout << &arr;
  17.     return 0;
  18. }
  19.  
  20.  
Error : Expected unqualified-id
Oct 21 '19 #1
1 1700
dev7060
638 Recognized Expert Contributor
A class can only contain data members and member functions. Hence the functionality must be present in member functions.
Oct 21 '19 #2

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

Similar topics

13
by: Charulatha Kalluri | last post by:
Hi, I'm implementing a Matrix class, as part of a project. This is the interface I've designed: class Matrix( )
3
by: Jack Middleton | last post by:
Hi! I'm lookin for a faster permutation algorithm for matrices. I know that it can be done with multiplying a matrix with a permutation matrix. It just seems a waste to iterate through all those...
1
by: genojoe | last post by:
I want to right-align numbers in a combobox. Since there is no TextAlign property for the ComboBox, I tried the following code in a form containing a default combobox. 'Declarations and two...
6
by: kilter | last post by:
Anyone know of a routine that will return the number of rows and columns in a matrix?
21
by: =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= | last post by:
Hello, I´m using a very large 2-dimensional double matrix (45.000x45.000) in my program. At the initialization of the matrix: double matrix = new double I am getting an out of memory...
3
by: lancered | last post by:
Hi dear all, I am using Python2.4.2+NumPy1.0.1 to deal with a parameter estimation problem with the least square methods. During the calculations, I use NumPy package to deal with matrix...
7
by: lethek39 | last post by:
Hey I have been trying to figure out how to sum rows and columns in a matrix square. I also have been trying to get the program to list the numbers of the diagonal in the matrix. So far this is the...
3
by: PeteJ | last post by:
Hello all.. I wrote code in C to invert n x n matrices, where 1<n<39 and the matrices are guaranteed to be invertible. Prior to this task, I haven't really seen linear algebra since my sophmore...
1
by: Sozos | last post by:
Hi guys. I have a problem with writing the base case for the following matrix multiplication function I have implemented. Please help. #define index(i,j,power) (((i)<<(power))+(j)) void...
2
by: Chris Winton | last post by:
I am trying to do some matrix multiplication but i keep getting a expected declaration at the end of input. Any help would be much appreciated. /* Description:To multiply given to matrix using...
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
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
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
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...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.