Thread: (pattern *) pat & pattern * pat

  1. #1
    Registered User
    Join Date
    Mar 2003

    (pattern *) pat & pattern * pat

    what is the difference between 1 & 2?

    1. pat = (PATTERN *)

    2. pat = PATTERN * vector(1,(int)*num_patfiles,sizeof(PATTERN));

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    look at it this way


    this returns something. My guess is a pointer of some sort.

    (PATTERN *)

    this is a cast.So putting the 2 together you are casting the result of vector(blahblah) to a PATTERN* or a pointer to a PATTERN and storing that in the variable pat.

    pat = PATTERN * vector(1,(int)*num_patfiles,sizeof(PATTERN));

    This on the other hand is a multiplication. It shouldn't compile as pointers cant be multiplied. This says multiply PATTERN with the result of vector(blahblah) and store the result in pat.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visitor / Decorator Pattern
    By MarkZWEERS in forum C++ Programming
    Replies: 9
    Last Post: 05-16-2009, 11:53 AM
  2. Hmm.. Ai? Finding the pattern in number squences?
    By Zeusbwr in forum C++ Programming
    Replies: 8
    Last Post: 04-02-2005, 06:13 PM
  3. Abstract Factory pattern
    By Just in forum C++ Programming
    Replies: 3
    Last Post: 02-18-2005, 10:58 AM
  4. string pattern search problem
    By goron350 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 08:50 AM
  5. text pattern recognition
    By mtsmox in forum C++ Programming
    Replies: 5
    Last Post: 02-27-2002, 08:38 AM