Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C++
#include<iostream>
#include<stdlib.h>
using namespace std;

class vector
{
	int *v;
	int size;
    public:
	vector(int m)
	{
		v=new int[size=m];
		for(int i=0;i<size;i++)
		{
			v[i]=0;
		}
	}
	vector(int *a)
	{
		for(int i=0;i<size;i++)
		{
			v[i]=a[i];
		}
	}
	int operator*(vector &y)
	{
		int sum=0;
		for(int i=0;i<size;i++)
		{
			sum +=(this->v[i])* (y.v[i]);
		}
		return sum;
	}
};
int main()
{
	int x[3]={1,2,3};
	int y[3]={4,5,6};
	vector v1(3);
	vector v2(3);
	v1=x;
	v2=y;
	int R=v1*v2;
	cout<<"R="<<R;
	return 0;
}


What I have tried:

i am not able to edit code,kindly help me.
Posted
Updated 3-Jul-17 12:47pm
v2
Comments
David_Wimbley 3-Jul-17 14:14pm    
You didn't specify a problem with your code. What is wrong with it? Do you expect us to figure out what is wrong with it and provide you the solution?

You need to realize we know nothing about what you are trying to accomplish nor can we see what is on your hard drive, I would suggest you use Improve question link on your post and update your question with a clearly defined explanation of your issue.
Member 13289423 19-Jul-17 11:58am    
i am requesting to correct it code.

1 solution

Quote:
How to correct it below code

First step is to tell us why you think the code is wrong. We can't help you because we don't know what your code is supposed to do in first place.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900