I have a question about the usage of parentheses and square brackets in OpenSees's code. The following code is a small section from the OpenSees source code, I guess the both "connectedExternalNodes(0)" and "theNodes[0]" means the first cell of "connectedExternalNodes" and "theNodes" array respectively. But why the former uses parentheses while the latter uses square brackets? The lower code is another similar example with the same question. Thank you very much in advance!
#####################################
// Set connected external node IDs
connectedExternalNodes(0) = nd1;
connectedExternalNodes(1) = nd2;
theNodes[0] = 0;
theNodes[1] = 0;
#####################################
q(0) += q0[0];
q(1) += q0[1];
q(2) += q0[2];
#######################################
question about parentheses and square brackets
Moderators: silvia, selimgunay, Moderators
-
- Posts: 93
- Joined: Thu Feb 12, 2009 8:31 pm
- Location: The University of Tokyo
Re: question about parentheses and square brackets
Thankyou so much, it really helped alot!!
Re: question about parentheses and square brackets
theNodes, q0 are array's and the [] are used in c or c++ to reference a member of the array.
q, connectedNodes are of type vector and id, these are c++ classes i have defined which have overloaded operators (). these () operators also access the components, but check the range of the indices is valid.
q, connectedNodes are of type vector and id, these are c++ classes i have defined which have overloaded operators (). these () operators also access the components, but check the range of the indices is valid.
-
- Posts: 1
- Joined: Tue Sep 11, 2012 2:26 am
- Location: USA
- Contact:
Re: question about parentheses and square brackets
Thanks for the greatest news about parentheses and square brackets. It's really help to everyone.............
-
- Posts: 140
- Joined: Sun Oct 03, 2010 11:36 pm
- Location: Hong Kong
Re: question about parentheses and square brackets
Yes, very helpful!
Matrix belongs to arrays, right?
Matrix belongs to arrays, right?
Research Assistant Professor, The Hong Kong Polytechnic University
guanlin@polyu.edu.hk
guanlin@polyu.edu.hk