Thread: Expression-must-have-pointer-to-object-type

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    144

    Expression-must-have-pointer-to-object-type

    What does the above error mean? I have typdef Coeffs as double and I'm trying to use it in func1
    Line 18: Poly --> expression must have pointer to object type


    Code:
    typedef double Coeffs;
    
    int main()
    {
    	Coeffs Poly;
    
    	...
    }
    
    func1(Coeffs Poly, int num_verts, double*coeff)
    {
    	double A, B, C, D;
    	int i, j;
    	A = B = C = D = 0;
    	for(i=0;i<num_verts;i++)
    	{
    		j = (i+1) % num_verts;
    		A += ((Poly[j][1] - Poly[i][1]) * (Poly[i][2] + Poly[j][2]));
    		B += ((Poly[j][2] - Poly[i][2]) * (Poly[i][0] + Poly[j][0]));
    		C += ((Poly[j][0] - Poly[i][0]) * (Poly[i][1] + Poly[j][1]));
    	}
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    In func1, Poly is a Coeffs, therefore Poly is a double, hence Poly[j][1] does not make sense.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 03-20-2012, 08:29 AM
  2. error: expression must have pointer-to-object type
    By MRZ1101 in forum C Programming
    Replies: 3
    Last Post: 02-29-2012, 10:05 AM
  3. Expression must have a pointer type
    By ArunS in forum C Programming
    Replies: 2
    Last Post: 06-23-2011, 03:27 AM
  4. Noob Question regarding Pointer-to-Object type
    By Drysdale in forum C++ Programming
    Replies: 2
    Last Post: 11-21-2010, 02:45 AM
  5. "void* is not a pointer-to-object type"
    By Envergure in forum C++ Programming
    Replies: 3
    Last Post: 01-18-2009, 08:21 AM